Question about using CatalogAware
Greetings, I've got a ZClass with ObjectManager and CatalogAware as base classes (in that order). I'd like to make a DTML Method (in the ZClass) that searches the catalog. Here's the method: <dtml-call "REQUEST.set('topurl', PARENTS[0].absolute_url())"> <dtml-if "category == 'top'"> <dtml-call "REQUEST.set('searchfor', {'metatype' : 'KMArticle', 'top' : 'on', 'current' : 'on'})"> <dtml-else> <dtml-call "REQUEST.set('searchfor', {'metatype' : 'KMArticle', 'category' : category, 'current' : 'on'})"> </dtml-if> <dtml-in "_[default_catalog](searchfor)" sort=score> <dtml-if "release.isPast()"> <dtml-var list_item> <dtml-else> <dtml-if sequence-start> <dtml-call "REQUEST.set('nofirst', 1)"> </dtml-if> </dtml-if> </dtml-in> And I get the following error: <STRONG>Error Type: AttributeError</STRONG><BR> <STRONG>Error Value: no __call__ method defined</STRONG><BR>
From the traceback: (Object: _[default_catalog](searchfor)) File <string>, line 0, in ? AttributeError: (see above)
A test DTML Method showed me that default_catalog = 'Catalog'. I have a ZCatalog called 'Catalog' in the Zope root. Since the ZClass is an Object Manager, the Method is one level down and will have to acquire the catalog. If I replace "_[default_catalog](searchfor)" with "Catalog(searchfor)", the method works. Any ideas what I'm doing wrong? Thanks, Kevin
At 06:23 PM 8/4/99 -0400, Kevin Dangoor wrote: ...
<STRONG>Error Type: AttributeError</STRONG><BR> <STRONG>Error Value: no __call__ method defined</STRONG><BR>
From the traceback: (Object: _[default_catalog](searchfor)) File <string>, line 0, in ? AttributeError: (see above)
If I replace "_[default_catalog](searchfor)" with "Catalog(searchfor)", the method works.
_[spam] gives you a *rendered* spam (yum!). _.getitem(spam,0) gives you the raw spam without rendering it. Try "_.getitem(default_catalog,0)(seachfor)" -Amos P.S. This is kind of documented in the DTML Guide, http://www.zope.org/Documentation/Guides/DTML/DTML-HTML/DTML.4.3.2.3.html
participants (2)
-
Amos Latteier -
Kevin Dangoor