[mod_python] quick code review

Greg Stein gstein at lyra.org
Mon May 29 12:36:10 EST 2000


On Mon, 29 May 2000, Gregory Trubetskoy wrote:
> On Thu, 25 May 2000, Greg Stein wrote:
> 
> > *) rather than storing the "request object" into r->notes, place it into
> >    tstate->dict. you won't have to do the atoi() stuff (which is Bad
> >    anyways)
> 
> This won't work. Or rather it will, but it's getting too complex to be
> worth it. 
> 
> The problem is that a single request can span multiple thread states - a
> typical scenario is when there is a PythonAuthenHandler directive
> somewhere in a parent directory and a PythonHandler directive in a
> subdirectory. The two handlers will be executed in different
> subinterpreters, thereofre having different tstates and result in two
> separate requestobjects being instantiated. 

All right. Fair enough.

Apache will use a single thread, but the multiple interpreters is a good
point (that I hadn't seen).

>...
> It seems to me that I am working around what is really an Apache
> limitation. The request_rec is clearly the right place to store a pointer
> to a requestobject for that request_rec, the limitation is that the place
> alloted for these sorts of things (r->notes) only deals with strings.

True.

> I think there needs to be something similar to r->notes that can take a
> pointer. For now, I think I'm going to revert to the atoi stuff...

At least use atol(). Still far from portable, but better.

(in the "ascii" scheme, the "best" would be to use PyLong_FromVoidPtr(),
 then convert that long to a string; reverse that sequence for the other
 direction)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/




More information about the Mod_python mailing list