Can your catalog live in root '/' site rather than 'accumac' site. Utilities are looked up in local sites than if not found they will be looked up in parent site and so on until root site is hit. I don't think utility look up will go on to search across in sites not in the same branch.
Alen On Fri, 2005-09-30 at 16:33 -0600, Duncan McGreggor wrote: > I have a multiple sites on a zope3 instance (folders at the top level > that have their own site managers). In one of them, there is page > content object with a custom view for portraying search results from > its (local) catalog. However, I have had a great deal of difficulty > getting the catalog I want. Here is the pertinent code for three > attempts, the last of which "worked". > > Attempt #1 > > class HomePageView(BrowserView): > def inventoryInStock(self): > catalog = zapi.getUtility(ICatalog, > name='accumac_catalog', > context=self.context) > return catalog.searchResults(equipment_in_stock=[True]) > > Attempt #2 > > class HomePageView(BrowserView): > def inventoryInStock(self): > sm = zapi.traverse(self.context, '++etc++site') > catalog = sm['default']['accumac_catalog'] > return catalog.searchResults(equipment_in_stock=[True]) > > Attempt #3 > > class HomePageView(BrowserView): > def inventoryInStock(self): > sm = zapi.traverse(self.context, '/accumac/++etc++site') > catalog = sm['default']['accumac_catalog'] > return catalog.searchResults(equipment_in_stock=[True]) > > > The first attempt got the catalog at the root of the zope 3 instance if > I passed no name; if I passed the name of the local catalog, I got the > following error: > > ComponentLookupError: (<InterfaceClass > zope.app.catalog.interfaces.ICatalog>, 'accumac_catalog') > > A clue as to why this happened may be in attempt #2. The error for > attempt #2 was: > > TraversalError: (<accumacsite.homepage.HomePage object at 0x2e688f0>, > 'site') > > And this might be a clue; it made me think that if the HomePage content > object was traversable, in both attempt #1 and #2, the correct catalog > would have been found. > > In attempt #3, I had zope traverse to the absolute location of the > local site manager, and from there got the correct catalog, with the > results being returned properly. However, this last attempt seems > rather hackish, as it uses a path and hard-coded names. I'd really like > to do this the right way. > > Does anyone have advice on this? > > Thanks! > > Duncan > > _______________________________________________ > Zope3-users mailing list > Zope3email@example.com > http://mail.zope.org/mailman/listinfo/zope3-users _______________________________________________ Zope3-users mailing list Zope3firstname.lastname@example.org http://mail.zope.org/mailman/listinfo/zope3-users