Lost with navigation using objectValues
I just try to automatically get a list of subfolders, following the example in the ZopeBook <http://www.zope.org/Members/michel/ZB/SimpleExamples.html>. Here is my code, in a DTML method in the root folder: <ul> <dtml-in expr="objectValues('Folder')"> <li><a href="<dtml-var absolute_url>"> <dtml-var title_or_id></a></li> </dtml-in> </ul> If I call it from /index_html, it works fine. If I call it from any other document anywhere, I just get <ul></ul> (so I'm sure the method has been called) but nothing else as if objectValues sent nothing (no need to say that I *have* subfolders an I also tried without the 'Folder' restriction, with the same result). Any advice? Zope RPM 2.2.2 on RedHat 6.2. Zope version: Zope 2.2.2 (source release, python 1.5.2, linux2) Python version: 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- System Platform: linux-i386 Process ID: 17906 (4101) Running for: 2 hours 55 min 45 sec
Stephane Bortzmeyer wrote:
my code, in a DTML method in the root folder:
Are you sure you put it in a DTML Method and not a DTML Document? The code looks fine.
If I call it from /index_html, it works fine. If I call it from any other document anywhere, I just get <ul></ul> (so I'm sure the method has been called) but nothing else as if objectValues sent nothing (no need to say that I *have* subfolders an I also tried without the 'Folder' restriction, with the same result).
This leads me to believe that it's in a DTML Document. It is looking in the current documents namespace and not in the root folder namespace. HTH, -- Tim Cook, President -- Free Practice Management,Inc. | http://FreePM.com Office: (901) 884-4126 Censorship: The reaction of the ignorant to freedom.
On Wed, Dec 13, 2000 at 11:31:34AM -0600, Tim Cook wrote:
Are you sure you put it in a DTML Method and not a DTML Document?
Well, viewing the object through the management interface says so. To be sure, I created a new object from scratch and changed the standard_html_header to use it. Same problem. Could it be an error in the calling code? I just say: <dtml-var navbar> [That's a problem I often have with Zope. Things which seems very basic suddenly become blocking problems.]
Stephane Bortzmeyer wrote:
Could it be an error in the calling code? I just say:
<dtml-var navbar>
If the calling code is within a DTML Document, then yes. The DTML Method is within the calling namespace. You would need to set up the correct namespace first using dtml-with or PARENTS[x] where x is the proper namespace level of the aquisition tree (Jim Fulton is probably either laughing or choking at my description but it works for those of us still struggling <s>).
[That's a problem I often have with Zope. Things which seems very basic suddenly become blocking problems.]
It's just that aq_ thing. :-) -- Tim Cook, President -- Free Practice Management,Inc. | http://FreePM.com Office: (901) 884-4126 Censorship: The reaction of the ignorant to freedom.
On Wed, Dec 13, 2000 at 12:20:34PM -0600, Tim Cook wrote:
If the calling code is within a DTML Document, then yes. The DTML Method is within the calling namespace.
OK, I understand, now, the ZopeBook was far from clear on this example.
You would need to set up the correct namespace first using dtml-with or PARENTS[x] where x is the proper namespace level of the aquisition tree (Jim Fulton is probably either laughing or
Peter Bengston sent me the proper syntax: <dtml-in expr="PARENTS[0].objectValues('Folder')"> and it works (with DTML documents, of course). Many thanks to all, this is user support.
On Wed, Dec 13, 2000 at 11:31:34AM -0600, Tim Cook wrote:
Are you sure you put it in a DTML Method and not a DTML Document?
OK, I get you: my code is in a DTML method but it was ultimately called by DTML documents, which produced the wrong result. If I create a DTML method, it works. After reading the excellent "DTML documents vs DTML methods" HOWTO, it makes sense but it is quite surprising. Does it mean I have to turn all my DTML documents into DTML methods if I want them to call DTML methods, even if they are only content?
I can seem to figure out what wrong here. I have ZPatterns installed already 0.4.3b2 This is the latest LoginManager 0.8.8b1 LoginManager Import Traceback Traceback (innermost last): File "/usr/share/zope/lib/python/OFS/Application.py", line 397, in import_products product=__import__(pname, global_dict, global_dict, silly) File "/usr/share/zope/lib/python/Products/LoginManager/__init__.py", line 1, in ? import LoginManager, LoginMethods, UserSources File "/usr/share/zope/lib/python/Products/LoginManager/LoginManager.py", line 7, in ? from Products.ZPatterns.PlugIns import PlugInGroup File "/usr/share/zope/lib/python/Products/ZPatterns/__init__.py", line 1, in ? import Rack, Specialists, Customizers, AttributeProviders, SheetProviders File "/usr/share/zope/lib/python/Products/ZPatterns/Rack.py", line 9, in ? from DataSkins import DataSkin File "/usr/share/zope/lib/python/Products/ZPatterns/DataSkins.py", line 1, in ? from DynPersist import DynPersist ImportError: No module named DynPersist
The source for DynPersist is in a sub-directory of ZPatterns. You have to go in and compile it. On Wed, 13 Dec 2000, Mohan Baro wrote:
I can seem to figure out what wrong here.
I have ZPatterns installed already 0.4.3b2
This is the latest LoginManager 0.8.8b1
LoginManager Import Traceback Traceback (innermost last): File "/usr/share/zope/lib/python/OFS/Application.py", line 397, in import_products product=__import__(pname, global_dict, global_dict, silly) File "/usr/share/zope/lib/python/Products/LoginManager/__init__.py", line 1, in ? import LoginManager, LoginMethods, UserSources File "/usr/share/zope/lib/python/Products/LoginManager/LoginManager.py", line 7, in ? from Products.ZPatterns.PlugIns import PlugInGroup File "/usr/share/zope/lib/python/Products/ZPatterns/__init__.py", line 1, in ? import Rack, Specialists, Customizers, AttributeProviders, SheetProviders File "/usr/share/zope/lib/python/Products/ZPatterns/Rack.py", line 9, in ? from DataSkins import DataSkin File "/usr/share/zope/lib/python/Products/ZPatterns/DataSkins.py", line 1, in ? from DynPersist import DynPersist ImportError: No module named DynPersist
_______________________________________________ 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 )
Stephane Bortzmeyer wrote:
Does it mean I have to turn all my DTML documents into DTML methods if I want them to call DTML methods, even if they are only content?
DTML Rule of Thumb (according to Tim): "Only use DTML Documents when you want an object to have persistent properties. All DTML Code goes into DTML Methods." -- Tim Cook, President -- Free Practice Management,Inc. | http://FreePM.com Office: (901) 884-4126 Censorship: The reaction of the ignorant to freedom.
participants (4)
-
Bill Welch -
Mohan Baro -
Stephane Bortzmeyer -
Tim Cook