Hi, What is the difference between <dtml-call "...."> and <dtml-call ...>. For instance, if I have this directory structure: | +-base +-subfolder from base, <dtml-call subfolder.manage_addFolder(...)> doesn't add any folders, while <dtml-call "subfolder.manage_addFolder(...)"> behaves as expected. It took about an hour of experimenting before getting this right. Could someone explain what is the difference here? Thanks. Chui
On Fri, 3 Mar 2000, Chui Tey wrote:
Hi,
What is the difference between <dtml-call "...."> and <dtml-call ...>. For instance, if I have this directory structure:
[snip]
<dtml-call subfolder.manage_addFolder(...)> doesn't add any folders, while <dtml-call "subfolder.manage_addFolder(...)"> behaves as expected. It took about an hour of experimenting before getting this right. Could someone explain what is the difference here?
Calling tags with and without quotes follows mostly the same convention throughout Zope. A tag without quotes, such as: <dtml-var myMethod> is equivalent to: <dtml-var name=myMethod> This says, "Include the variable with the name myMethod." The alternate form is: <dtml-var "myMethod()"> which is equivalent to: <dtml-var expr="myMethod()"> This says, "Include the result of the Python expression in quotes, myMethod()." In your specific case, dtml-call without quotes is equivalent to using the name form, and thus does nothing. There is no attribute or method called subfolder.manage_addFolder(...). Note that Zope would be looking for this, literally, and would not interpret the period as an application of a method to an instance. Using the dtml-call tag with quotes is equivalent to the expr form, and will thus interpret the period appropriately. To convince yourself that this is the case, try including a DTML Method using the expr form without parenthesis: <dtml-var expr="myMethod"> puts this in the response: <function myMethod at 8071cf8> If you view this in a browser, you will not see it because your browser will try and interpret it as a <function ...> tag, which, of course, does not exist.
Thanks.
Hope this helps.
Chui
--Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
----- Original Message ----- From: "Jeff Hoffman" <jeff.hoffman@goingv.com> To: "Chui Tey" <teyc@bigfoot.com> Cc: <zope@zope.org> Sent: Friday, March 03, 2000 1:11 AM Subject: Re: [Zope] <dtml-call >
<dtml-var myMethod>
is equivalent to:
<dtml-var name=myMethod>
This says, "Include the variable with the name myMethod."
It's also worth mentioning that when you do this to call DTML Methods and External Methods some things automatically get passed in. When you use the expression form, these things are not passed in. The most important thing is that the namespace is passed along to DTML Methods and this() and REQUEST are passed along to external methods. I haven't looked at the python source to know exactly what is passed in these cases, but you generally will get what you want if you do this for DTML Methods: <dtml-var "myMethod(_.None, _)"> and this for external/python methods: <dtml-var "myMethod(this(), REQUEST)"> Kevin
participants (3)
-
Chui Tey -
Jeff Hoffman -
Kevin Dangoor