[mod_python] PSP buffer?

Jim Dabell jim-mod-python at jimdabell.com
Thu Aug 12 18:37:17 EDT 2004


I'm just getting stuck into mod_python, and I've hit a bit of a snag.  I am 
writing a handler, but would like to use PSP to construct a few pages.  So 
I'm instantiating a PSP object, and using its run() method to execute it.

Unfortunately, that just repeatedly calls req.write(), which doesn't give me 
the opportunity to perform any operations on the result before it is sent to 
the client, or even output additional headers afterwards.  For instance, I 
can't find a way of producing a Content-Length header, or using content 
encoding to gzip the response body.  run() actually calls req.write with 
flush=0, but then explicitly calls flush() afterwards.

For the moment, I'm working around this by passing a proxy object that 
intercepts write() and flush() to the PSP constructor.  This seems like a 
pretty fragile hack to me though, and I was wondering if there was a better 
way of accomplishing what I am after, or plans to make PSP more flexible in 
later releases.

As far as I can tell, my only other options are:

a) Dump PSP
b) Alter psp.py
c) Dump my handler and use the PSP handler.

None of these are particularly attractive options to me.  Does anybody have 
any better suggestions?  Google, the FAQ and the manual didn't turn up 
anything particularly inspiring.

-- 
Jim Dabell



More information about the Mod_python mailing list