[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Hooking python callback functions to a svn_client_ctx_t

From: Greg Stein <gstein_at_lyra.org>
Date: 2003-05-06 22:54:43 CEST

On Mon, May 05, 2003 at 10:55:32PM +0200, Philipp von Weitershausen wrote:
> cmpilato@collab.net wrote:
> ...
> >>Sure, I can see in svn_client.h that svn_client_ctx_t wants a
> >>svn_cancel_func_t, but if the above does not work, how can I hook my
> >>python callbacks up to the client context?
> >
> >I don't think it *can* be done today. I've not gotten around to
> >making that work just yet. It's on my TODO list, though.
> What would have to be done in order to support that?

Create a special "setter" wrapper function for those members of the
structure. Take a Python callable object, store that as the cancel baton,
and put in a "thunk" for the cancel function.

As an example of the callable object -> func/baton, take a look at how the
func/baton pairs are handled in svn_client.i.

There is probably some other SWIG magic to do custom handling of the get/set
for the members of a structure. IOW, you might be able to say "there is a
member named cancel_func in the svn_client_ctx_t structure which a Python
program can read/write, but there is no cancel_baton member."

(the baton doesn't need to be exposed since the cancel function can simply
 be a bound method, meaning your "baton state" can be stored as instance
 variables in the bound object)

Last note: since we moved all of the notify/log/etc func/baton pairs into
the client context, we might even be able to simplify svn_client.i since
those data types won't appear as parameters. Would need to check. But
whatever pattern is used to deal with the cancel func/baton structure
members *would* definitely apply to the func/baton pairs in the client
context structure.


Greg Stein, http://www.lyra.org/
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 6 22:54:07 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.