On 13 April 2010 20:41, Manlio Perillo <manlio_peri...@libero.it> wrote: >>> So, when executing a sub request, it is necessary to flush (that is, >>> send to Nginx, in my case) the content generated from the template >>> before the sub request is done. >> >> This seems to only makes sense if you're saying that the subrequest *has >> to* send its output directly to the client, rather than to the parent >> request. > > Yes, this is how subrequests work in Nginx. And I assume the same is > true for Apache.
No that is not true for Apache. Apache content handlers write output into what is called a bucket brigade. For a normal sub request this may be the bucket brigade of the parent request and so be processed by the output filters of the parent request. You can however code the mechanics of the sub request to override that and do something else with the data pushed into that bucket brigade. Although it can be done it gets a bit complicated to have the data written back into the bucket brigade pulled back into the context of a parent request. This is because the data is written from the context of the sub request where as at same time the parent request is going to want to pull it. Thus need to use threading and have to fire off the sub request in its own thread with a queue of some sort being used to communicate between the two. So messy, but technically it should be possible with custom Python code specific to Apache to fire off a subrequest and the result of the sub request be an iterable which yields data which itself could be yielded from the context of the parent application such that the content could then be processed and modified by a WSGI middleware wrapper. Graham _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com