[Zope] PythonScripts and REQUEST, RESPONSE objects

Alex Verstraeten alex@quad.com.ar
Tue, 6 Mar 2001 23:48:58 -0300


Hello zop'ers

I'm doing most of my work with pythonscripts but I have some problems with
it:

whenever a pythonscript needs to invoke objects like REQUEST or RESPONSE, I
have to put those objects at the paramter list and then, when invoking the
pythonscript I have to pass those objects to it.

This brings me 2 problems:
the syntax is much longer, instead of having:
<dtml-var MyMethod>
I have to type now:
<dtml-var "MyMethod(RESPONSE=RESPONSE , REQUEST=REQUEST)">

the other problem is that from now on this object requires to be called from
a dtml-method (because it needs these RESPONSE and REQUEST objects as
parameters)

is there a cleaner solution than doing this?

back to my php days, I remember a similar issue with variable scopes on
functions, but there were 3 workarounds to access those out-of-scope
variables:

1. pass it in the argument list (just like in pythonscript)
2. declare the variables as global (global $foo, $bar)
3. access them thru a $GLOBAL['foo'] $GLOBAL['bar']

is there any similar solution at python script like example 2 and 3? or is
it a must to pass those objects in the parameter list? if that's the case:
how am I supposed to invoke those pythonscripts from other pythonscripts?

so far I've noticed dtml methods being very limited in functionality (but at
least they can reach any object) while pythonscript is very flexible in
functionality but way too annoying to be used,  as it sometimes depends on
dtml methods to be called from, so it can be passed objects that cant reach
by itself.
Isnt there a more integrated and independant solution than this ugly
dmtl/pythonscript method mixture ?

Hope to be wrong about all this.
if I am, please let me know =)


Thanks.

Alex