passing context using expr="dtml_method()"?
Folks, Newbieish question. When I am calling a dtml method using a dtml tag such as <dtml-var mymethod> it appears to pass the namespace of the calling document. However, when I am calling a dtml method using the expr syntax, such as <dtml-var expr="mymethod()"> it doesn't. For instance, a <dtml-var title_or_id> in the tag calling version will pick up the title of the calling document, and in the expr syntax version will not unless I explicitly pass the title_or_id variable as a parameter to the call. I am trying to organize a project into a semblance of order with subfolders at this point, and it would be very handy to be able to pass the calling document namespace wholesale to my dtml-methods, instead of having to pass each variable the method is going to use explicitly. Is there some simple way to do this that I am missing in the documentation? Thanks. -- John Withers <jwithers@nautilus.org>
John Withers wrote:
Newbieish question.
Please read the Zope-Book for self-answering newbiesih questions. http://zope.org/Documentation/Books/ZopeBook/2_6Edition
When I am calling a dtml method using a dtml tag such as <dtml-var mymethod> it appears to pass the namespace of the calling document.
However, when I am calling a dtml method using the expr syntax, such as <dtml-var expr="mymethod()"> it doesn't.
Taken from the Zope-Book: http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ScriptingZope.stx """Note that DTML Methods and Documents take optional client and REQUEST parameters. If a client is passed to a DTML Method, the method tries to resolve names by looking them up as attributes of the client object. By passing our context as a client, the method will look up names in that context. Also, we can pass it a REQUEST object and additional keyword arguments - the DTML Method will first try to resolve names in them.""" Use <dtml-var expr="mymethod(None, _)"> Cheers, Maik
John Withers wrote at 2003-12-4 10:07 -0800:
... When I am calling a dtml method using a dtml tag such as <dtml-var mymethod> it appears to pass the namespace of the calling document.
However, when I am calling a dtml method using the expr syntax, such as <dtml-var expr="mymethod()"> it doesn't.
Reading "Calling DMTL objects" in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> may help you. -- Dieter
participants (3)
-
Dieter Maurer -
John Withers -
Maik Jablonski