[mod_python] Capturing PSP output

Joshua Ginsberg listspam at flowtheory.net
Mon May 30 12:19:02 EDT 2005

Hello --

I'm trying to do something a little unorthodox... I didn't know if 
anybody had tried it before... Within a PSP page, I want to run another 
PSP page and capture the output to a string.

To do a little testing, I wrote the following PSP page:


def sAppend(self, thestring):
     if '__s__' not in dir(self):
         self.__s__ = ''
     self.__s__ += str(thestring)

oldReqWrite = req.write

req.write = sAppend

req.write = oldReqWrite
<!-- <%=req.__s__%> -->

But that errors out with:

Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 29
9, in HandlerDispatch
     result = object(req)
File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 297,
in handler
File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 208,
in run
     exec code in global_scope
File "/var/www/signup/test.psp", line 12, in ?
File "/var/www/signup/test.psp", line 5, in sAppend
     self.__s__ =
AttributeError: 'str' object has no attribute '__s__'
Dispatch() returned non-integer.

Any thoughts on how to do this? Thanks!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: unknown.jpg
Type: image/jpeg
Size: 1984 bytes
Desc: not available
Url : http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050530/05170592/unknown.jpg
-------------- next part --------------

Joshua Ginsberg -- joshg at brainstorminternet.net
Brainstorm Internet Network Operations
970-247-1442 x131

More information about the Mod_python mailing list