[mod_python] Re: Redirects

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Oct 21 10:44:47 EST 2002


On Sun, 20 Oct 2002, vio wrote:

> Got you. To be more precise, my little code example was "mod_python/2.7.8
> over Apache/1.3.26" friendly.
>
> So I guess you must be referring to mod_python/3 running on apache/2.
> Looking foreword to it (sorry I haven't had much time to play with the beta
> releases so far ... lazily waiting for the first stable release, I guess, to
> migrate to the new generation). If I understand you correcly, no more 'fast
> track' access to REQUEST internals (aka. 'XXX._req') :-(. I guess a little
> 'migration tips to mod_python/3' might become handy, then).
>

The _req object came about as a way to make the end-user request object
modifiable. There were two ways of doing it - writing C code to make the
built-in request object accept new members, or simply encapsulate it in a
regular Python object. I hose the latter because it was quicker :)

Mod_python 3 does it correctly - the built-in request object won't need to
be encapsulated, it will be modifiable as is, so there won't be any need
for _req.

BTW, the ._req is undocumented, so if ever anyone used it, it was at their
own risk. And yes, a migration document would be nice, hopefully I can put
something together to that extent.

> If I may add a coding style suggestion for the new version out of the blue,
> it would be to replace all references to 'req' with 'REQUEST' (uppercase
> full name). I learned this in Zope long ago, and it sticked with me: it's a
> little more verbose, but so much more clean when you look at a source code,
> especially true for newcomers. Good ideas deserve to be "borrowed".

I don't like the way Zope names it REQUEST, because to me, a part-time C
programmer, all caps means a symbolic constant, and this convention has
for the most part been followed in Python standard library.

Grisha

>
> Vio
>
>
> "Gregory (Grisha) Trubetskoy" wrote:
>
> > On Sat, 19 Oct 2002, vio wrote:
> >
> > > You do redirection in mod_python with something like this:
> > >
> > >
> > > def handler(REQUEST):
> > >
> > >    _REQUEST = REQUEST._req
> >
> > The above line won't work starting with the next version of mod_python...
> >
> > Grisha
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
>





More information about the Mod_python mailing list