From: Dieter Maurer *EXTERN* [mailto:dieter@handshake.de]
Reif Peter writes:
... My script:
... ##bind namespace=namespace ...
zone = namespace.zone return zone
It is called from a DTML-method where the tag <dtml-var zone> is rendered correctly:
... <dtml-var get_status_a> ...
Error:
Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: zone How is it called?
Implicitly (<dtml-var myPythonScript>) or explicitly?
In the second case, you must pass the namespace yourself! In the first case, check in the binding tab that the binding really took place.
PythonScripts are quite picky with the binding comments at their start. A minor typo and part of the comments are no longer recognized.
My variable is named "zone". The following Python-statement yields 1: return namespace.has_key("zone") The following calls yield an error (each one): return namespace.items() return namespace.keys() return getattr(namespace, "zone") I am using Zope-2.4.0 --- A second test with explicit calling: DTML method: <dtml-let xy="test"> <dtml-var expr="get_status_a(ns=_)"> </dtml-let> python script get_status_a: ## Script (Python) "get_status_a" ##bind container=container ##bind context=context ##bind namespace=namespace ##bind script=script ##bind subpath=traverse_subpath ##parameters=ns ##title= return ns.has_key("xy") # OK, yields 1 return ns.xy # ERROR: Error Type: AttributeError, Error Value: xy