[mod_python] idea for PSP

vincent delft vincent_delft at yahoo.com
Sat Feb 28 00:41:08 EST 2004


By adding 'global_scope.update({"echo":req.write})' in
psp.py at line 208 (mod_python 3.1.3), we create a new
function called "echo" (like in php) that fit my
original requirement (mail post before with same
subject).

Does this idea is Thread safe ... et cetera.

This simplify the psp coding. Like I've explained in
my previous mail, we will able to do :

...
<% 
for i in range(5):
   echo "<br>Hello"
#end
%>
...


OK. My example is not the best one, but I think psp
writters will see the idea.
It's not always so easy to use the "last indentation"
feature. 
This "echo" command is an "elegant" (up to you to
confirm) alternative to "building string" within the
loop.

 
Thanks












--- "Gregory (Grisha) Trubetskoy"
<grisha at modpython.org> wrote:
> 
> 
> On Wed, 25 Feb 2004, vincent delft wrote:
> 
> > adapt the psp.py code by using an "exec" (instead
> of eval) and redirect
> > sys.sdtout to req.write just before the execute.
> 
> "print" is what the original mod_psp.c used,
> actually.
> 
> The problem is that in a multithreaded
> configuration, there is only one
> sys.stdout for multiple requests, so one thread
> cannot assign to it
> without affecting others :-)
> 
> Grisha


__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools


More information about the Mod_python mailing list