use of objectValues() in DTML Methods vs. DTML Documents
Hi, I'm working my way through the beta-book on zope.org and having a blast generally but I'm hoping someone can check my thinking here and tell me if I'm on the right track. Thanks in advance for any insight you can offer. In chapter 3, where DTML is first introduced, they have me create a Folder with some files in it and include something like this in a DTML Method: <dtml-in expr="objectValues('File')"> <a href="&dtml-absolute_url;"><dtml-var title_or_id></a><br> </dtml-in> Just for the heck of it I dropped that same code into a DTML Document in the same Folder and it didn't list the Files as I had expected. I understand pretty much the differences of Methods and Documents and I'm assuming the reason for this is related to the way the Documents exists in it's own namespace and the Method doesn't... so my best guess for this behavior is that the 'scope' of objectValues() is limited to the current namespace. Am I even close? If not can someone explain this to me? Thanks! Mike Bannister geekteam.com
Mike Bannister wrote:
Just for the heck of it I dropped that same code into a DTML Document in the same Folder and it didn't list the Files as I had expected. I understand pretty much the differences of Methods and Documents and I'm assuming the reason for this is related to the way the Documents exists in it's own namespace and the Method doesn't... so my best guess for this behavior is that the 'scope' of objectValues() is limited to the current namespace.
Am I even close? If not can someone explain this to me?
This is quite a thorny FAQ. The root of it is the binding of methods to objects/namespaces in DTML, which has had lots of press on zope-dev@zope.org recently. The short version is: -if that code is in a method, it is executed on the method's container (actualyl acquisition context, but don't worry abotu that too much ;-) -if the code was in a documents, it is executed on that document. Since documents can't really have things attached to them that would be returned by objectValues, you usually get an empty list back :-) HTH, Chris
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Mike Bannister Sent: Wednesday, October 25, 2000 5:44 AM To: zope@zope.org Subject: [Zope] use of objectValues() in DTML Methods vs. DTML Documents
Just for the heck of it I dropped that same code into a DTML Document in the same Folder and it didn't list the Files as I had expected. I understand pretty much the differences of Methods and Documents and I'm assuming the reason for this is related to the way the Documents exists in it's own namespace and the Method doesn't... so my best guess for this behavior is that the 'scope' of objectValues() is limited to the current namespace.
Am I even close? If not can someone explain this to me?
That's basically it, yes. I think of a method as being a function that works on the object it is "in", and a document as being an object that gets worked on. So objectValues() in a method will return objects from its container, whereas objectValues() in a document will always return objects from within that document. Acquisition plays a role too, since a method can work in different contexts. For example (given myMethod and myDocument that both use objectValues()) TestFolder1.myMethod will return objects in TestFolder1 TestFolder2.myMethod will return objects in TestFolder2 TestFolder1.myDocument will return objects in myDocument TestFolder2.myDocument will return objects in myDocument I hope this makes sense. _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
participants (3)
-
Chris Withers -
Mike Bannister -
Ron Bickers