[mod_python] I can access mod_ssl cert env vars using PerlAuthenHandler, but howto do it with a PythonAuthenHandler?

perry.tew at cibavision.novartis.com perry.tew at cibavision.novartis.com
Thu Oct 2 16:09:00 EST 2003


Grisha,
   Thanks for the tip!  I'll try that tonight. 

About the infinite recursion issue  ... yeah, I struggled with that a lot. 
 The perl code I had did the following:

 return OK unless $r->is_main;

to prevent this loop.  I had something in my handler like this:

if req.prev:
        return apache.OK

but I took it out and the handler didn't seem to hang.  Quite strange. 
It's obvious I have some more
learning to do.  I'll continue experimenting.


If I may ask you a different question along the lines of authentication. I 
have need to cache roles and acls for urls
in order to prevent hitting a database for every request.   I need a way 
to cache these values and have each of
my child processes access them.

1.  I'm using the "worker" MPM.  Is that acceptable for use with 
mod_python?  I haven't had a problem yet with it.
2. Is there a preferred way of sharing data among the different children? 
dbm? berkley db? IPC?   I don't mind 
file based persistance, but I'm ignorant of the fastest and safest way to 
cache this data.  Any thoughts would be
appreciated.

Something else I thought of was that I guess I could jack up the number of 
threads per child and limit the number of
children to something small.  Would that not keep the number of caches 
down to 3 or 4 ( 1 per child )?

I'm really enjoying mod_python.  Thanks for writing it.
Perry Tew







On Wed, 1 Oct 2003 perry.tew at cibavision.novartis.com wrote:

> So, my perl code looks like this:
> ##########################################
> my $subr = $r->lookup_uri($r->uri);
> my $env = $subr->subprocess_env;
> my $cn = $env->{'SSL_CLIENT_S_DN_CN'};
> my $dn = $env->{'SSL_CLIENT_S_DN'};
> ##########################################

It looks like mod_perl's lookup_uri returns the new request object, which
is rather clever, we should adopt this in mod_python :-)

> I'm trying to do the same thing in python with this:
> ############################################
>         req.internal_redirect(req.unparsed_uri)
>         req.add_common_vars()
>         for k, v in req.subprocess_env.items():
>                 msg = k + "=" + v
>                 apache.log_error( msg , apache.APLOG_NOTICE )
>
> ############################################

Try this instead:

         req.internal_redirect(req.unparsed_uri)
         req.next.add_common_vars()
         for k, v in req.next.subprocess_env.items():
                 msg = k + "=" + v
                 apache.log_error( msg , apache.APLOG_NOTICE )


Notice "req.next" instead of "req"

Also - don't know if your handler does this elsewhere, but I think that
req.internal_redirect(req.unparsed_uri) would create an infinite recursion
unless you check that you are not in a subrequest by examining req.prev.

Grisha





More information about the Mod_python mailing list