Newbie still having problems understanding namespaces
I'm sure this is a case of RTFM, but I think I may be reading the wrong FM! Looking at the DTML reference section n the Zope Book (PDF version) on page 228, I see a set of DTML functions which I had assumed I could call, for example: <dtml-var expr="abs(-23)"> which I would have expected to evaluate to 23. Instead I get the error: Error Type: NameError Error Value: global name 'abs' is not defined. I guess this is because abs is not in the current nemespace. My question is where is the documentation that tells me which namespace to use and when? TIA Dave Lambert
Hi David, try <dtml-var expr="_.abs(-23)"> David Lambert wrote:
I'm sure this is a case of RTFM, but I think I may be reading the wrong FM! Looking at the DTML reference section n the Zope Book (PDF version) on page 228, I see a set of DTML functions which I had assumed I could call, for example:
<dtml-var expr="abs(-23)"> which I would have expected to evaluate to 23.
Instead I get the error:
Error Type: NameError Error Value: global name 'abs' is not defined.
Thanks for your quick response. At last I think I am getting the hang of this. One other related question is: What is the differnce between: ZopeTime(), and _.DateTime()? TIA Dave. On Thursday 09 August 2001 14:56, E. Seifert wrote:
Hi David,
try <dtml-var expr="_.abs(-23)">
David Lambert wrote:
I'm sure this is a case of RTFM, but I think I may be reading the wrong
FM!
Looking at the DTML reference section n the Zope Book (PDF version) on
page
228, I see a set of DTML functions which I had assumed I could call, for example:
<dtml-var expr="abs(-23)"> which I would have expected to evaluate to 23.
Instead I get the error:
Error Type: NameError Error Value: global name 'abs' is not defined.
_______________________________________________ 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 )
"'ZopeTime' will return a the output of DateTime.now() which is a DateTime object" 'DateTime' objects are an "Encapsulation of Python module DateTime" Quotes are from the Zope Quick Reference (ZQR) - Check it out :) http://www.zope.org/Members/ZQR Eric.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of David Lambert Sent: Thursday, August 09, 2001 1:04 PM To: E. Seifert; zope@zope.org Subject: Re: [Zope] Newbie still having problems understanding namespaces
Thanks for your quick response. At last I think I am getting the hang of this. One other related question is: What is the differnce between:
ZopeTime(), and _.DateTime()?
TIA
Dave.
On Thursday 09 August 2001 14:56, E. Seifert wrote:
Hi David,
try <dtml-var expr="_.abs(-23)">
David Lambert wrote:
I'm sure this is a case of RTFM, but I think I may be reading the wrong
FM!
Looking at the DTML reference section n the Zope Book (PDF version) on
page
228, I see a set of DTML functions which I had assumed I could call, for example:
<dtml-var expr="abs(-23)"> which I would have expected to evaluate to 23.
Instead I get the error:
Error Type: NameError Error Value: global name 'abs' is not defined.
_______________________________________________ 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 )
_______________________________________________ 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 )
Hi David, Well, to make it work: <dtml-var "_.abs(-23)"> That's one, of probably many, ways to do it. As for the discussion of Zope and namespaces, I'll leave that to those who have already explained it more eloquently than I ever could. Search the mailing list archives for 'namespace' and you'll find many posts with great explanations. Good luck, Eric.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of David Lambert Sent: Thursday, August 09, 2001 12:46 PM To: Zope Subject: [Zope] Newbie still having problems understanding namespaces
I'm sure this is a case of RTFM, but I think I may be reading the wrong FM! Looking at the DTML reference section n the Zope Book (PDF version) on page 228, I see a set of DTML functions which I had assumed I could call, for example:
<dtml-var expr="abs(-23)"> which I would have expected to evaluate to 23.
Instead I get the error:
Error Type: NameError Error Value: global name 'abs' is not defined.
I guess this is because abs is not in the current nemespace. My question is where is the documentation that tells me which namespace to use and when?
TIA
Dave Lambert
_______________________________________________ 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 )
<dtml-var expr="abs(-23)"> which I would have expected to evaluate to 23.
Instead I get the error:
Error Type: NameError Error Value: global name 'abs' is not defined.
I guess this is because abs is not in the current nemespace. My question is where is the documentation that tells me which namespace to use and when?
Try <dtml-var expr="_.abs(-23)"> which should work. Why? Take this with a grain of salt, because I'm not certain I'll get it correct: When you use an expression, you are in the document's namespace. 'abs' is a function in the DTML namespace (the namespace of DTML itself, not an object using DTML.) To get DTML's namespace, which allows you to use DTML things to get to the current object's namespace, you use the magic underscore '_'. Thus you can get to DTML functions, use indexing to get values, &c. That's my best shot at explaining it. Of course, that's probably all wrong. I just know how to do it, not necessarily how it works. --jcc
participants (4)
-
David Lambert -
E. Seifert -
Eric Walstad -
J. Cameron Cooper