A Dexterity item usually has its meta_type set to 'Dexterity Item' or 'Dexterity Container'. That is available in the catalog metadata.
how to know if result brains are Archetypes or Dexterity based objects?
-
12-01-2022 - |
Вопрос
Is there a way to know if an object is Archetypes-based or Dexterity-based using only the brains resulting from a catalog search?
Решение
Другие советы
I don't think that this information is indexed, but it can be easily retreived by getting the FTI. The lookup can be cached when handling large result sets.
I think something like this should work:
from plone.dexterity.interfaces import IDexterityFTI
from zope.component.hooks import getSite
from Products.CMFCore.utils import getToolByName
def is_dexterity(brain):
ttool = getToolByName(getSite(), 'portal_types')
fti = ttol.get(brain.portal_type)
return IDexterityFTI.providedBy(fti)
Не связан с StackOverflow