Dale Hirt wrote:
> Here is as good as any a place to ask. What's the question?
Apologies for the long post, trying to give all relevant information.
I am trying to imitate in Python the calls that mod_authz_svn (1.2.1) makes
via the Subversion C API. In mod_authz_svn.c the call tree looks like this:-
-> apr_pool_userdata_get(&user_data, cache_key, pool)
-> svn_config_read(&access_conf, path to conf file, TRUE, pool)
-> svn_config_enumerate(cfg, repos_path, callback, baton)
My python code so far looks like this:-
def my_cb(name, value, baton):
config = svn.core.svn_config_read("/path/to/auth.conf", True, pool)
svn.core.svn_config_enumerate(config, "/path/to/repos", my_cb, baton)
if __name__ == "__main__":
The code is running on the same server as the subversion repository.
The svn_config_read() works fine. The svn_config_enumerate() gives me this:-
Traceback (most recent call last):
File "./x.py", line 16, in ?
File "/usr/local/subversion-1.2.1/lib/svn-python/svn/core.py", line 40, in
return apply(func, (pool,) + args, kw)
File "./x.py", line 13, in my_func
"/cluster_b/data/svn-repositories/sysadmin", my_callback, config)
TypeError: Expected a pointer
I've tried all kinds of ways of changing the four arguments to
svn_config_enumerate(). I have two problems:
1. How can I tell which of the four arguments is the problem? I've looked at
the C code and arguments 1, 3 and 4 must all be objects and can all cause a
swig "Expected a pointer" error.
2. If it is argument four that is the problem how on Earth do I provide a
value to it? What type? I don't even care about the baton since all that
happens is it is passed to my callback and my callback doesn't need a value.
In C that argument is typed as void*, i.e. you can pass the address of
anything and the callback can dereference it because it knows (since I wrote
it) what data to expect at the given address, SVN doesn't need to care.
My investigations so far:-
Changing arg1 from config to 1 or None or an arbitrary variable still yields
the pointer error.
Changing arg1 from config to "" gives "TypeError: Type error. Got , expected
_p_svn_config_t". Looks good but confused by response above to other types.
Changing arg2 from a string to None gives "TypeError: svn_config_enumerate()
argument 2 must be string, not None". Looks good.
Changing arg3 from my_callback to None causes *no error whatsoever* ! So that
kinda implies that argument 3 is the problem. In which case how do I provide
the callback function to svn_config_enumerate() ?
Anything arg4 is set to causes the same error. Hmm that kinda makes me think
that it doesn't care (as I'd expect) what it's given and arg3 is the problem.
I've searched a lot yesterday on Google, and read some of the SWIG
documentation about type maps, and asked briefly in #svn-dev on IRC (after
#svn told suggested I go to #svn-dev) and there was told to read the trac
source code. The trac source code wasn't very helpful.
I've read chapter 8 of the SVN book (1.1 and latest). I've read
I do *NOT* want to use PySvn.
I've seen some information about using a client context attribute to specify a
callback and have seen an example of this regarding auth but don't really
understand what a client context is or what attributes it has and how to pass
a method/func name in to the subversion API I'm trying to call. I suspect the
auth case is special in that the API there will look for a particular
attribute on the context object and expect it to be the name of or a reference
to a python function to invoke ala a callback.
I'd really be interested in documenting the Python via SWIG api. I started a
docs/user contributions custom php web project for NSIS (Nullsoft Scriptable
Install System, http://nsis.sf.net/) which survived for about two years before
recently being replaced by a Wiki and was very useful for the community. I'd
love to do something similar for this. It was my own need that drove the NSIS
effort and the same is true now.
The server has SWIG 1.3.21, Python 2.3.4, Subversion 1.2.1, Linux 2.6.9-5
(RedHat Enterprise Linux ES release 4 Nanant Update 1) and I am running FSFS
To unsubscribe, e-mail: firstname.lastname@example.org
For additional commands, e-mail: email@example.com
Received on Mon Sep 12 19:43:59 2005