[mod_python] PSP content-type problem

Robert Fendt rmfendt at web.de
Tue Sep 28 01:24:43 EDT 2004

And thus spake "Gregory (Grisha) Trubetskoy" <grisha at modpython.org>
Mon, 27 Sep 2004 10:40:50 -0400 (EDT):

> But how would that work? The PSP object uses the request object to send 
> its output, which in turn sends it out the filter stack and out to the 
> socket.
> To get a string, you'd need a fake request object that uses a StringIO or 
> something to buffer the output, but this output isn't going to reflect the 
> real picture because it would not be subject to any other filter/module in 
> httpd, and if the PSP page makes use of any request specific features 
> (e.g. internal redirect), the fake request object isn't going to support 
> it. The bottom line is not nearly as simple as it seems. :-)

Okay, point taken. But its behaviour has to be at least properly
documented. IMHO the docs are seriously lacking in regard to PSP, anyway.

The problem about the content-type remains, however. I still cannot
understand why the default has to be set outside the PSP object at all. Doing it like that is error-prone and produces redundant code.

I may not be a Python guru, but usually something like that is done in an
object's constructor (i.e., __init__() in Python). So what would by the
problem about doing it during instantiation? It would be much cleaner and
you would not have to check if it is initialised at various parts of the
code. Or we do not initialise it, and the request object itself checks it
upon first call to write(), setting it to text/html if needed. What about


More information about the Mod_python mailing list