You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Scott Collins <sc...@ScottCollins.net> on 2003/06/06 19:12:51 UTC

how to write a notify_func in python?

I'm trying to write a Python script that watches an |snv_client_update| 
and mirrors the result up to a remote website on which I can't directly 
have a repository, and to which my only access is ftp.

To do this, I think I want to write a |svn_wc_notify_func_t|.  At the 
urging of sussman, I'm trying to use the python bindings.  I couldn't 
find anything in svn/tools/examples that looked like a good model for 
this.  In fact, no callbacks written in Python were apparent to me in 
these sources at all.  After reading all about SWIG, I see that it 
doesn't _directly_ support implementing callback functions in the 
scripting language, however, it's still possible through `thunks' 
involving special script-environment-aware calls.  I see the code that 
does this for the callback I want to implement.  It's 
|svn_swig_py_notify_func| and its implementation starts in the 
neighborhood of line 901 in svn/subversion/bindings/swig/swigutil_py.c.

It's not obvious how I'm supposed to use this from Python.  The name 
doesn't show up in any of the Python svn modules directly.  It does 
appear, however, in svn_wc.i (an input file that helps generate the 
swig bindings) where I see:

   /* 
-----------------------------------------------------------------------
      handle svn_wc_notify_func_t/baton pairs
   */

   %typemap(python,in) (svn_wc_notify_func_t notify_func, void 
*notify_baton) {

     $1 = svn_swig_py_notify_func;
     $2 = $input; /* our function is the baton. */
   }

I can't tell from this how to build a function in Python that can be 
used as such a callback, nor can I find any examples.  Help?
__________
Scott Collins <http://ScottCollins.net/>