[Zope] Passing namespace from DTML to Python Script
Chris Withers
chrisw@nipltd.com
Thu, 24 May 2001 10:51:41 +0100
Hi,
I want to call a python script from DTML and pass the namespace, the trouble is,
the PS needs to be called from a python expression in DTML.
So, taking the simple DTML method:
<dtml-var standard_html_header>
<dtml-let test_thang="'Test Thang'">
<dtml-var "test_ps" html_quote>
</dtml-let>
<dtml-var standard_html_footer>
...and a simple python script (with namespace bound to _):
return _['test_thang']
..which of coruse, doesn't work, it gives me:
<PythonScript instance at 01B17ED0>
..so change <dtml-var "test_ps" html_quote> to <dtml-var "test_ps()" html_quote>
and now I get:
Error type: KeyError
Error value: test_thang
...fair enough thinks me, I need to do the old dtml trick and so change to:
<dtml-var "test_ps(_.None,_)" html_quote>
...and now I get:
Error type: TypeError
Error value: no arguments expected
...OK, irritating, but lets try changing the parameter list to 'context, _':
Finally I get what I want:
Test Thang
However, now I want to call it somewhere else as just <dtml-var test_ps>, I get:
Error type: TypeError
Error value: not enough arguments; expected 2, got 0
...at this point my head exploded and I thought I'd mail the list. Can anyone
explain how Ishould eb doing this?
cheers,
Chris