Re: [Zope] "global name 'REQUEST' is not defined"
hans wrote:
Joseph A Knapka wrote:
Er... OK... It works fine if I use a DTML /document/ rather than a DTML /method/. So are DTML methods totally useless or what? </flamebait>
Cheers,
-- Joe
Joseph A Knapka wrote:
Hello, all,
Once again, it seems I must be misunderstanding something very basic. I have a DTML method that's being called from a DTML document, and it contains the code:
<dtml-if expr="REQUEST.get(field_var)"> ... </dtml-if>
where field_var is a dtml variable that has been set to the name of another dtml variable that certainly exists in the parent document. For example, field_var == "lastname", and the parent DTML document has either received "lastname=Blah" in its request, or has done "REQUEST.set('lastname','')" if not. But the code above yeilds an error:
"global name 'REQUEST' is not defined".
Since it's defined in the parent document, shouldn't it also be defined for the DTML method? According to "The Book of Zope" the REQUEST object is defined "for the duration of the web request"; surely that must include the invocation of DTML methods within the target document?
Thanks in advance,
http://www.zope.org/Members/michel/ZB/AppendixB.dtml says: __call__(client=None, REQUEST={}, **kw)
maybe, you should pass REQUEST explicitly, like <dtml-call "your_method(this(), REQUEST, _.None)">
Ah, now I understand. If I want to pass *any* arguments to the method, I must also explicitly pass REQUEST. But if I call the method without arguments, it will magically be passed the caller's REQUEST. Thanks, -- Joe "I should like to close this book by sticking out any part of my neck which is not yet exposed, and making a few predictions about how the problem of quantum gravity will in the end be solved." --- Physicist Lee Smolin, "Three Roads to Quantum Gravity"
Joseph A Knapka writes: ... passing arguments to DTML objects is a *MUST*! ...
Ah, now I understand. If I want to pass *any* arguments to the method, I must also explicitly pass REQUEST. But if I call the method without arguments, it will magically be passed the caller's REQUEST. Please read the section "Calling DTML objects" in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> You will find out that your description is not completely true (but near the truth). Dieter
participants (2)
-
Dieter Maurer -
Joseph A Knapka