Monday, October 27, 2008

Query portal catalog by interface: object_provides

Edit 2010-05-19: This is now a how-to on

Suppose you have several types (for example, event types like 'Birthday','Wedding','Graduation') in your portal which implement the same interface (for example, IIsCauseForCelebration), and you want to get items of these types from the catalog.
Rather than name the types explicitly (like portal_type=['Birthday','Wedding','Graduation' ]) you may query the wanted interface:

from import IIsCauseForCelebration

This has the additional advantage that if products added or modified later add types which implement the interface, these new types will also show up in your query.

No comments: