[mod_python] Python API for doing subrequests? (was 'lookup')

Graham Dumpleton grahamd at dscpl.com.au
Sat Sep 2 19:26:25 EDT 2006

On 03/09/2006, at 1:25 AM, Chad Whitacre wrote:

> All,
>> It looks like mod_perl has API for performing subrequests,  
>> lookup_uri and lookup_file:
>> http://www.samspublishing.com/articles/article.asp? 
>> p=27110&seqNum=17&rl=1
>> I don't see anything parallel in mod_python. Has this ever been  
>> discussed?
> I do see a "main" attribute on the request object with this doc:
>  "If this is a sub-request, pointer to the main request."
>  http://www.modpython.org/live/current/doc-html/pyapi-mprequest- 
> mem.html
> So it appears that it's possible to be called as a subrequest, but  
> I'm not seeing a Python API for making that call. Eh?

The closest you will get is the ability to trigger an internal redirect.

The mod_python method is:

     Internally redirects the request to the new_uri. new_uri must be  
a string.
     The httpd server handles internal redirection by creating a new  
request object
     and processing all request phases. Within an internal redirect,  
req.prev will
     contain a reference to a request object from which it was  



This method is a wrapper for Apache ap_internal_redirect() function. For
mod_perl it should also have an equivalent call which wraps the Apache
ap_internal_redirect() function. It isn't either the two mod_perl  
functions you
quote though.

Besides an internal redirect, there is no other way in mod_python to  
sub requests. Not sure how practical it may be to support the other  
for performing sub requests in mod_python, would need to look into it.

What exactly is it you want to do?


More information about the Mod_python mailing list