[mod_python] Setting req->user for mod_dav_svn

Deron Meranda deron.meranda at gmail.com
Tue Aug 1 13:11:19 EDT 2006


On 8/1/06, Jim Gallacher <jpg at jgassociates.ca> wrote:
> Deron Meranda wrote:
> > When you say req.user is writable, is that just for the member of the
> > Python "req" object, or does a write also modify the underlying
> > Apache C structure's request_rec->user  (char*) member?
>
> request_rec->user is set.
>
> Here is the relavent bit from requestobject.c (3.2.10) in the
> setreq_recmbr function (line 1279):
>     ...
>     ...
>
>     else if (strcmp(name, "user") == 0) {
>         if (! PyString_Check(val)) {
>             PyErr_SetString(PyExc_TypeError, "user must be a string");
>             return -1;
>         }
>         self->request_rec->user =
>             apr_pstrdup(self->request_rec->pool, PyString_AsString(val));
>         return 0;
>
> Jim

Thanks Jim.  That's what I was hoping it did.

I'm now down to thinking this must be a DAV or SVN thing.  I can use
the builtin CGI handler along with my mod_python access handler and
can see that the request_rec->user is getting set (which shows up
as the REMOTE_USER environment variable in the CGI script).

   # .htaccess
   PythonAccessHandler setmyuser::accesshandler
   SetHandler cgi-script

   # setmyuser.py
   from mod_python import apache
   def accesshandler(req):
       req.user = 'foobar'
       return apache.OK

   #!/bin/sh
   # dump.cgi
   echo "Content-Type: text/plain"
   echo
   echo "User is" $REMOTE_USER
   exit 0

   $ wget -O - http:..../dump.cgi
   User is foobar

So somehow either mod_dav or mod_dav_svn must not be getting
this or need something more.  More code diving....
-- 
Deron Meranda


More information about the Mod_python mailing list