On Fri, 2005-09-30 at 18:34 -0600, Duncan McGreggor wrote: > > Can your catalog live in root '/' site rather than 'accumac' site. > > Honestly, this would be a partial defeat of the usefulness of having > the ability to make folders into full-blown sites.
You can also nest sites, create a folder, make it a site, and then have your three sites as sub-sites of the parent 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. > > The accumac site is where the catalog is, but it is also where the > content it... it's the context of the whole app. For instance, the > homepage content object lives here: > > /accumac/index.html > > Instances of the equipment content object are here: > > /accumac/equipment > > And the catalog for the site is here (and it's the only catalog > instance in the local site): > > /accumac/++etc++site/default/accumac_catalog > > The IntId instance lives parallel to the local catalog, too. Does this > explain the layout better? If not, then I have misunderstood your > comment... My understanding was that your zapi.getUtility() was not finding your catalog and that you had three parallel sites from which you were doing the catalog look up and the catalog was only in one of them, accumac site: /accumac/++etc++site/default/accumac_catalog I guess the success of the catalog look up depends on what your self.context is when you are doing zapi.getUtility(), i.e. where you are looking up the catalog from. I would expect your code to find the catalog when self.context is inside accumac site, but would not expect the catalog to be found from inside the other two sites. But then again I might be misunderstanding your problem :) > > d > > > > > 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 _______________________________________________ Zope3-users mailing list Zope3email@example.com http://mail.zope.org/mailman/listinfo/zope3-users