[Zope] different namespaces in a python script by calling it by <dtml-var xxx> and <dtml-var "xxx()">?

Grégoire Weber gregoire.weber@switzerland.org
Thu, 19 Jul 2001 12:16:26 +0200


Hi people there!

I have a problem with namespace in python scripts. 
I found a lot namespace Q&A but I didn't find any 
pointers about the following in the list archive:

I have a python Script 'xxx' and a DTML method 
'xxxcaller' (code below). 

I discovered that namespaces depend on the method how 
the 'xxx' script is called by the 'xxxcaller' DTML
method. It works as expected if I do a <dtml-var xxx> 
and magically unexpected if I do a <dtml-var "xxx()">.

The output of 'xxxcaller' is:

  <dtml-var xxx> --> foo
  <dtml-var "xxx()"> --> sort_order not defined 

Why that?

Greg

------------------------------------------------- xxx
## Script (Python) "xxx"
##bind container=container
##bind context=context
##bind namespace=_
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
if _.has_key('sort_order'): return _['sort_order']
else: return 'sort_order not defined'

------------------------------------------------- xxxcaller
<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p>
<dtml-let sort_order="'foo'">
&lt;dtml-var xxx&gt; --> <dtml-var xxx><br>
&lt;dtml-var "xxx()"&gt; --> <dtml-var "xxx()">
</dtml-let>
</p>
<dtml-var standard_html_footer>

_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org