[mod_python] Re: sending headers directly to the client

Mike Looijmans nlv11281 at natlab.research.philips.com
Mon May 15 07:50:23 EDT 2006


>> When the user submits the request, immediately return a page that  
>> says something like "processing your request, please wait...".
>>
>> The simplest thing to do is to just output that on the result page,  
>> and flush() the request output. Then do as you normally do.
>>
>> The "please wait" could be removed with javascript or so.
>>
>> Another option is to first return a "please wait" HTML page. This  
>> page has a redirect header, that loads the actual result page. The  
>> user gets to see the redirecting page until the result page is done.
> 
> 
> Noting though that you may need a caching system for the result of  
> database
> query which is accessible from multiple processes. This is because if  
> Apache
> prefork MPM being used, or even worker with multiple processes, the
> subsequent request to get the results of the query will not  necessarily 
> end
> up at the same Apache child process. Thus, you can't rely on caching  
> within
> an Apache child process.

One way to avoid that issue is by making sure the intermediate page does 
not do anything useful. Simple example (untested code, probably loaded 
with bugs but it might illustrate what i mean):

<form action=search.psp>
   Search: <input name=s type=text>
   <input type=submit value="Go">
</form>


in search.psp:


<%
req.headers_out.put('refresh', '1;url=dosearch.psp?s=%s' % 
urlencode(form['s']))
%>
<H1>Please wait</H1>
...


in dosearch.psp:


<H1>Result</H1>
<%=VeryBigImpressivelySlowQueryResult%>




More information about the Mod_python mailing list