[Product-Developers] Restricting search in portal catalog not working?

Johannes Schwenk johannes.schwenk at gmail.com
Fri Feb 27 19:01:05 UTC 2009


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

This should return all objects under ./vocabulary providing the 
ICategorizerVocabTerm interface. But I *always* get the "vocabulary" object 
too, because it provides the interface also. It does not make any difference, 
whether I set "depth" to 1, 0 or whatever... Strange! I read in Martins Book, 
that depth=1 should leed to the wanted behaviour, beeing "all *sub*items 
under ./vocabulary that provide ICategorizerVocabTerm, *not* the item 
provided as path" !

What Do I do wrong?

Thank you!

Johannes

*  Plone 3.1.7
* CMF 2.1.1
* Zope (Zope 2.10.6-final, python 2.4.4, linux2)
* Python 2.4.4 (#1, Jan 28 2008, 15:57:09) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)]
* PIL 1.1.6





More information about the Product-Developers mailing list