[Zope] Reusing the global namespace of a DTMLFile from a Python method...

Dieter Maurer dieter at handshake.de
Tue Feb 24 14:52:51 EST 2004


Johan Carlsson wrote at 2004-2-23 20:34 +0100:
>Is there anyway to access the global namespacem, keyword arguments 
>passed to a DTMLFile when defined in a class, from a python method
>when the method is called from the DTML File, like this:
>
>
>class A(SomeBaseClass):
>
>	b=DTMLFile('dtml/manage_this', globals(), my_variable=1)
>
>	def c(self, client=None, REQUEST=None):
>		"""DocString"""
>		<get my_variable>
>
>dtml/manage_this:
>	<dtml-var std_header>
>	<dtml-var c>
>	<dtml-var std_footer>

Call your method explicitely and pass the namespace in:

     <dtml-var expr="c(_.None, _)">

In "c", you can then use "REQUEST['my_variable']"
(or "REQUEST.getitem('my_variable')").
You can use "REQUEST.has_key" to check for the existence of
a variable.

-- 
Dieter



More information about the Zope mailing list