Reusing the global namespace of a DTMLFile from a Python method...
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> -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM Skype: colliberty
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
participants (2)
-
Dieter Maurer -
Johan Carlsson