You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Stephen White <sw...@decisionsoft.com> on 2003/05/12 11:03:54 UTC

SWIG client bindings and auth_baton

It's my eventual aim to use the SWIG Java bindings, but I thought I'd 
start by using the Python bindings to understand how things should work 
before playing with the less complete Java ones.

However the code I'm looking at (gsvn) uses 
client.new_svn_client_auth_baton_t() - which doesn't seem to exist in 
thie current bindings.

Without this function I can't see any way to create an auth_baton_t with 
which to populate the client_ctx, and without doing that things tend to 
segfault.  Or at least that's why I think they're segfaulting.

Any thoughts?  My current assumption is that this was broken by the
recent move from libsvn_auth to libsvn_subr but I'm on a bit of a steep
subversion & SWIG learning curve right now.




On a totally unrelated note 'make swig-java' fails for me, I needs to do 
the following:

* Create the directory  
  subversion/bindings/swig/java/org/tigris/subversion/swig

* RUN_SWIG_JAVA uses 'cd' so the relative paths don't work/

Index: build/generator/gen_make.py
===================================================================
--- build/generator/gen_make.py (revision 5888)
+++ build/generator/gen_make.py (working copy)
@@ -211,7 +211,7 @@
       deps = string.join(sources)
       self.ofile.write('%s: %s\n\t$(RUN_SWIG_%s) %s\n'
                        % (objname, deps, string.upper(objname.lang_abbrev),
-                          os.path.join('$(top_srcdir)', sources[0])))
+                          os.path.join('$(abs_srcdir)', sources[0])))
 
     for objname, sources in self.graph.get_deps(gen_base.DT_OBJECT):
       deps = string.join(map(str, sources))


-- 
Stephen White                               +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Philipp von Weitershausen <ph...@weitershausen.de>.
cmpilato@collab.net wrote:
> I've look at it briefly.  I was a little disappointed that you
> combined your -noproxy stuff with a change that removed the remapping
> of svn_fs_FUNCTION_NAME to fs.FUNCTION_NAME (instead of
> fs.svn_fs_FUNCTION_NAME).

I actually *was* doing one thing at a time. Since SWIG doesn't do any 
renaming by default, it was using the functions names from the C header 
files which *do* contain the svn_fs_ prefix.

> Not sure I like that, though I agree that consistency is best.

Really, I find the getattr hack in fs.py ugly and repelling.

> My suggestion is to take this one task at a time -- do the -noproxy
> stuff first, and meanwhile we as a community should decide which way
> to go with the naming thing.

As I said, I did one thing at a time. Going back to the old naming in 
the fs module would be doing *two* things ;) And why should we do 
renaming in the first place before having discussed how to rename symbols?

> (While I like the shorter names, I think it'll come back to bite us
> as long as we continue to combine multiple svn interfaces into a
> single Python module -- take the 'util' module for example).

Well, you answered this question already: IMO we should have one python 
module for every header file.

Phil


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by cm...@collab.net.
Philipp von Weitershausen <ph...@weitershausen.de> writes:

> cmpilato@collab.net wrote:
> > As well it should.  I added the svn_auth.h header to the bindings
> > interface files a week or so ago, and used a script *very* similar to
> > Philipp's to verify that I could actually use the auth baton.
> 
> Talking about making changes to the binding interface files: has
> anyone reviewed my patch yet? I would *really* like to discuss this
> and see it in some form of another in the trunk so I can start
> supplying more code that is based on these changes.

I've look at it briefly.  I was a little disappointed that you
combined your -noproxy stuff with a change that removed the remapping
of svn_fs_FUNCTION_NAME to fs.FUNCTION_NAME (instead of
fs.svn_fs_FUNCTION_NAME).  Not sure I like that, though I agree that
consistency is best.

My suggestion is to take this one task at a time -- do the -noproxy
stuff first, and meanwhile we as a community should decide which way
to go with the naming thing.  (While I like the shorter names, I think
it'll come back to bite us as long as we continue to combine multiple
svn interfaces into a single Python module -- take the 'util' module
for example).

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Philipp von Weitershausen <ph...@weitershausen.de>.
cmpilato@collab.net wrote:
> 
> As well it should.  I added the svn_auth.h header to the bindings
> interface files a week or so ago, and used a script *very* similar to
> Philipp's to verify that I could actually use the auth baton.

Talking about making changes to the binding interface files: has anyone 
reviewed my patch yet? I would *really* like to discuss this and see it 
in some form of another in the trunk so I can start supplying more code 
that is based on these changes.

Phil


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by cm...@collab.net.
Philipp von Weitershausen <ph...@weitershausen.de> writes:

> Stephen White wrote:
> > Index: subversion/bindings/swig/util.i
> > ===================================================================
> > --- subversion/bindings/swig/util.i	(revision 5888)
> > +++ subversion/bindings/swig/util.i	(working copy)
> > @@ -232,6 +232,7 @@
> >  #define __attribute__(x)
> >   %include svn_io.h
> > +%include svn_auth.h
> >   %{
> >  #include <apr.h>
> 
> Weird. In my working copy, %include svn_auth.h appears in line 228 of
> the file, just two paragraphs above where you've inserted
> it. Therefore, my script works out of the box here...

As well it should.  I added the svn_auth.h header to the bindings
interface files a week or so ago, and used a script *very* similar to
Philipp's to verify that I could actually use the auth baton.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Stephen White <sw...@decisionsoft.com>.
> Weird. In my working copy, %include svn_auth.h appears in line 228 of 
> the file, just two paragraphs above where you've inserted it. Therefore, 
> my script works out of the box here...

Doh, it's there in my copy too - so after I added I actually ended up
with it twice.

The copy that was failing was actually my tarball of 0.22.0 which
doesn't have that line.  I then decided that the latest code from the
reposistory was the way to go and copied my changes into the new copy
without looking at what was around it before doing the 'svn diff' - on
the totally invalid assumption that not much would have changed between
0.22 and now.

Thanks,

-- 
Stephen White                               +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Philipp von Weitershausen <ph...@weitershausen.de>.
Stephen White wrote:
> Index: subversion/bindings/swig/util.i
> ===================================================================
> --- subversion/bindings/swig/util.i	(revision 5888)
> +++ subversion/bindings/swig/util.i	(working copy)
> @@ -232,6 +232,7 @@
>  #define __attribute__(x)
>  
>  %include svn_io.h
> +%include svn_auth.h
>  
>  %{
>  #include <apr.h>

Weird. In my working copy, %include svn_auth.h appears in line 228 of 
the file, just two paragraphs above where you've inserted it. Therefore, 
my script works out of the box here...

Phil


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Stephen White <sw...@decisionsoft.com>.
---- Original Message ----
> From Philipp von Weitershausen <ph...@weitershausen.de>
> Date: Monday, 12 May 2003, 15:15
>
> > Without this function I can't see any way to create an auth_baton_t with 
> > which to populate the client_ctx, and without doing that things tend to 
> > segfault.  Or at least that's why I think they're segfaulting.
> 
> The way to create an auth_baton now is to call util.svn_auth_open(). 
> Consider the following script:
> 
> # create the auth baton
> auth_baton = util.svn_auth_open(providers, pool)

Hmm, that doesn't seem to appear in the python bindings.

>>> from svn import util
>>> util.svn_auth_open
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'svn_auth_open'

However, I added svn_auth.h to util.i (see below) and rebuilt the Python
bindings and then your script worked a treat.


[swhite@ob subversion-svn]$ svn diff subversion/bindings/swig/util.i 
Index: subversion/bindings/swig/util.i
===================================================================
--- subversion/bindings/swig/util.i	(revision 5888)
+++ subversion/bindings/swig/util.i	(working copy)
@@ -232,6 +232,7 @@
 #define __attribute__(x)
 
 %include svn_io.h
+%include svn_auth.h
 
 %{
 #include <apr.h>



Thanks,

-- 
Stephen White                               +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Stephen White <sw...@decisionsoft.com>.
---- Original Message ----
> From Philipp von Weitershausen <ph...@weitershausen.de>
> Date: Monday, 12 May 2003, 15:15
>
> > However the code I'm looking at (gsvn) uses 
> > client.new_svn_client_auth_baton_t() - which doesn't seem to exist in 
> > thie current bindings.
> 
> The way to create an auth_baton now is to call util.svn_auth_open(). 
> Consider the following script:

Hmm, unfortunately nobody changed the Java bindings to match this.

-- 
Stephen White                               +44-1865-203192
DecisionSoft Limited                        http://www.decisionsoft.com
XML Development and Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: SWIG client bindings and auth_baton

Posted by Philipp von Weitershausen <ph...@weitershausen.de>.
Hi Stephen,

> However the code I'm looking at (gsvn) uses 
> client.new_svn_client_auth_baton_t() - which doesn't seem to exist in 
> thie current bindings.
> 
> Without this function I can't see any way to create an auth_baton_t with 
> which to populate the client_ctx, and without doing that things tend to 
> segfault.  Or at least that's why I think they're segfaulting.

The way to create an auth_baton now is to call util.svn_auth_open(). 
Consider the following script:

from svn import client, util

# create a pool; yes, this is quite disturbing for python programmers
pool = util.svn_pool_create(None)
# create a list of authentication providers for the auth baton
providers = [
     client.svn_client_get_simple_prompt_provider(pool),
     client.svn_client_get_simple_provider(pool)
     ]

# create the auth baton
auth_baton = util.svn_auth_open(providers, pool)

# create a client context (svn_client_ctx_t) to pass it to client
# functions
client_ctx = client.new_svn_client_ctx_t()

# attach the auth baton to the context
# WARNING: this might change due to my patch that I sent in recently
# (wonder when I might get some response for it)
# because using accessor functions really is ugly
client.svn_client_ctx_t_auth_baton_set(client_ctx, baton)

# we need a new revision
rev = util.new_svn_opt_revision_t()
svn_opt_revision_t_kind_set(rev, util.svn_opt_revision_head)

# now do something (e.g. checking something out)
client.svn_client_checkout(
     "file:///my/rep",
     "trunk",
     rev,
     1,     #recursive
     client_ctx,
     pool
     )

There you go. As I said in the comment, I have supplied a patch this 
weekend to eliminate these evil accessor functions. Structs are 
represented as classes then which is much nicer. It makes the code much 
cleaner and helps people understand the API better. I'm still waiting 
for the discussion on it, though

Cheers,
Phil


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org