subversion-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Роман Донченко <>
Subject Re: Question regarding the python binding
Date Thu, 25 Mar 2010 15:56:26 GMT
Tino Schwarze <> писал в своём письме Thu, 25
2010 17:17:42 +0300:

> Hi there,
> Back to python: I managed to use the Python bindings to get a value from
> the config file (I didn't want to reinvent the wheel) like this:
> ***
> from svn import repos, fs, delta, core, client
> def main(pool, repos_dir):
>     # for now, store client configuration in repository root
>     cfgfile = repos_dir+'/conf/client.conf'
>     svncfg = core.svn_config_read (cfgfile, True, pool)
>     global_ignores = core.svn_config_get (svncfg,  
> None)
> ***
> Now I'd like to verify our default set of required MIME types, so I need
> to get the contents of the [auto-props] section from the config file.
> libsvn provides the following function which should be suitable for my
> needs:
> svn_config_enumerate2(svn_config_t cfg, char section,
> svn_config_enumerator2_t callback, void baton, apr_pool_t pool) -> int
> Two questions arise:
> 1. How do I define an appropiate callback in Python? Looking at the SWIG
> documentation, I see examples on how to implement Python callbacks but
> they don't seem to match the current SVN bindings. I tried passing a
> Python method, deriving from svn_config_enumerator2_t etc. -> Segfault.

I took a look, and unfortunately this callback is not supported. The  
reason for that is that SWIG can't automatically figure out how to call  
Python callbacks, so a chunk of boring code must be written for each  
callback type - and I guess no developers needed to scratch this  
particular itch.

If it was supported, however, the call would look like this (and it *will*  
look like this, after I become un-busy again and implement it):

def enumerator(name, value, pool):
   print "%s: %s" % (name, value)

core.svn_config_enumerate2(svncfg, core.SVN_CONFIG_SECTION_AUTO_PROPS,  

> 2. What's the baton good for? Is it just some kind of additional data, I
> don't need to care about?

The baton argument is used up by the bindings themselves, you neither  
should nor can supply your own (this applies to all callbacks).

> Maybe the devel list is more appropiate for such questions, but I wanted
> to try here first.

Not really, since this is a use question. 8=]

> Thanks,
> Tino.


View raw message