[Product-Developers] Restricting search in portal catalog not working?
Johannes Schwenk
johannes.schwenk at gmail.com
Mon Mar 2 14:39:53 UTC 2009
Hi again,
> > Hi All,
> >
> > I have the following code in one of my content types:
> >
> > def get_vocab(self):
> > pc = getToolByName(self, 'portal_catalog')
> > query = {}
> > query['path'] = '/'.join(self.getPhysicalPath()) + '/vocabulary'
> > query['depth'] = 1
> > query['object_provides'] = ICategorizerVocabTerm.__identifier__
> > brains = pc.searchResults(**query)
> >
> > dl = DisplayList()
> > for term in brains:
> > dl.add(term['id'], term['Title'])
> >
> > return dl
> >
>
> The depth argument is being ignored. It is a parameter of the path index:
>
> query['path'] = {
> 'query': '/'.join(self.getPhysicalPath()) + '/vocabulary' }
> 'depth': 1,
> }
>
Thanks for your help! I tried your suggestion like this:
def get_vocab(self):
pc = getToolByName(self, 'portal_catalog')
query = {}
query['path'] = {'query' : '/'.join(self.getPhysicalPath())
+ '/vocabulary', 'depth' : 1}
query['object_provides'] = ICategorizerVocabTerm.__identifier__
brains = pc.searchResults(**query)
dl = DisplayList()
for term in brains:
dl.add(term['id'], term['Title'])
return dl
but get no results with this method either... When I omit the "depth"
paramether, I get results though. So there should be another way?!
Thanks,
Johannes
More information about the Product-Developers
mailing list