RE: [Zope] ZCatalog (2.3.1) won't acquire method from parent fold er?
Casey Duncan Wrote:
Solution: write a wrapper method in your class that looks for a DTML method to index against. If it finds one then call it or a default DTML method passing self as the client like so:
defaultSearchTextWeighted = Globals.HTMLFile('dtml/searchTextWeighted', globals()) def searchText(self): """Look for a DTML Method to call""" if hasattr(self, 'searchTextWeighted'): stw = self.searchTextWeighted else: stw = self.defaultSearchTextWeighted return stw(self)
Forgive my ignorance here, but this will evaluate/render the method (using the correct context of the class instance itself), and proxy the rendered method to the catalog machinery because it is a python class, post-rendered? Or is it that this wrapper returns the DTML method itself, wrapped in a correct context by which catalog renders the method? Sean
sean.upton@uniontrib.com wrote:
Casey Duncan Wrote:
Solution: write a wrapper method in your class that looks for a DTML method to index against. If it finds one then call it or a default DTML method passing self as the client like so:
defaultSearchTextWeighted = Globals.HTMLFile('dtml/searchTextWeighted', globals()) def searchText(self): """Look for a DTML Method to call""" if hasattr(self, 'searchTextWeighted'): stw = self.searchTextWeighted else: stw = self.defaultSearchTextWeighted
return stw(self)
Forgive my ignorance here, but this will evaluate/render the method (using the correct context of the class instance itself), and proxy the rendered method to the catalog machinery because it is a python class, post-rendered? Or is it that this wrapper returns the DTML method itself, wrapped in a correct context by which catalog renders the method?
Sean
Sorry this reply took so long, I have been away from the Zope world for a day and a half (and a lot is happening, yikes!). Basically this method calls the DTML method (either by acquiring one or using a default one) and makes sure that the context that the method is rendered in is the current object, by explicitly passing self to it. So, when the catalog calls this method, it returns the rendered DTML method in the context of the object. This compensates for the fact that the catalog calls an index method with not arguments. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (2)
-
Casey Duncan -
sean.upton@uniontrib.com