Hello everyone,
I try to access the REQUEST variable in a Python class, but in certain cases this gives me a real headache.
If I call my object with <dtml-var ObjectInstance>, then I can refer to the request variable in my Python code with self.REQUEST But, if I try: <dtml-var "ObjectInstance">, then I cannot use self.REQUEST, since the namespace is somehow not passed. BTW, the same seems to be true with properties inside a parent object. For some reason, if I call __getattr__, the entire "global namespace" (REQUEST and Aquisition) does not work correctly anymore.
Has anyone a clue for me?
Hi Stephan, <dtml-var ObjectInstance> does some zope-specific argument passing. This magic isn't available if you do <dtml-var "ObjectInstance()"> (notice the brackets, the way you did it would just cause to render something like <ObjectInstance at #2424234> and wouldn't call the object). If you do the above you have to explicitly pass the arguments, i.e. REQUEST and _. Take a look at dieter maurers excellent writings at http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html for instance for a concise explanation what kind of magic happens with dtml-var. cheers, olivver