Making a custom catalog for a specific content type

I'm trying to make a custom catalog for a specific content type. I was trying to follow this:
as an example, but I'm missing something that is allowing content to actually reindex itself.


class IMyObject(Interface):

    #Title and description provided by IBasic    

    Model_Number = schema.TextLine(title=u"",

    Serial_Number = schema.TextLine(title=u"",
                                    required = False

class MyObject(Container):
    def _catalogs(self):
        return [
                   getToolByName(self, 'portal_myobjectcatalog')

    def indexObject(self):
        for c in self._catalogs:

    def unindexObject(self):
        ''' remove an object from all registered catalogs '''
        path = '/'.join(self.getPhysicalPath())
        for c in self._catalogs():

    def reindexObjectSecurity(self, skip_self=False):
        path = '/'.join(self.getPhysicalPath())
        for c in self._catalogs():
            for brain in c.unrestrictedSearchResults(path=path):
                brain_path = brain.getPath()
                if brain_path == path and skip_self:
            # Get the object
            ob = brain._unrestrictedGetObject()

            # Recatalog with the same catalog uid.
            # _cmf_security_indexes in CMFCatalogAware

    def reindexObject(self, idxs=[]):
        ''' reindex object '''
        if idxs == []:
            # Update the modification date.
            if hasattr(aq_base(self), 'notifyModified'):
        for c in self._catalogs():
            if c is not None:


<?xml version="1.0"?>
<object name="portal_myobjectcatalog" meta_type="MyObjectCatalog">
  <property name="title">Index MyObject content on a site</property>
  <property name="unwrapobjects" type="boolean">True</property>
  .... lexicons
  .... default plone fields

  <!-- MyObject Related -->

  <index name="Model_Number" meta_type="ZCTextIndex">
    <indexed_attr value="Model_Number"/>
    <extra name="index_type" value="Okapi BM25 Rank"/>
    <extra name="lexicon_id" value="plone_lexicon"/>

  <index name="Serial_Number" meta_type="ZCTextIndex">
    <indexed_attr value="Serial_Number"/>
    <extra name="index_type" value="Okapi BM25 Rank"/>
    <extra name="lexicon_id" value="plone_lexicon"/>



class IMyObjectCatalog(Interface):
    """A specialized catalog to deal with MyObjects

class MyObjectCatalog(CatalogTool):
    """A specialized catalog to deal with MyObjects

    id = 'portal_myobjectcatalog'
    portal_type = meta_type = 'MyObjectCatalog'

    def getId(self):



class MyObjecttCatalogXMLAdapter(ZCatalogXMLAdapter):

    __used_for__ = IMyObjectCatalog
    adapts(IMyObjectCatalog, ISetupEnviron)
    name = 'myobjectcatalog'

    def _exportNode(self):
        Export the settings as a DOM node.
        node = ZCatalogXMLAdapter._exportNode(self)'My Object Catalog settings exported.')
        return node

    def _importNode(self, node):
       Import the settings from the DOM node.
        ZCatalogXMLAdapter._importNode(self, node)'My Object Catalog settings imported.')

def importMyObjectCatalog(context):
    Import portal_myobjectcatalog configuration.

    site = context.getSite()
    tool = getToolByName(site, 'portal_myobjectcatalog', None)

    if tool is None:
        logger = context.getLogger("my.product")"Catalog not installed.")

    importObjects(tool, '', context)

def exportMyObjectCatalog(context):
    Export portal_myobjectcatalog configuration.

    site = context.getSite()
    tool = getToolByName(site, 'portal_myobjectcatalog', None)
    if tool is None:
        logger = context.getLogger("my.product")"Nothing to export.")

    exportObjects(tool, '', context)



    ... Below <genericsetup:registerProfile>
        name="my.product "
        title="My Object Import Step"
            <depends name="toolset"/>

      title="My Object Catalog Export Step"
   <adapter factory=".exportimport.catalog.MyObjectCatalogXMLAdapter"/>  



<?xml version="1.0"?>
     <required tool_id="portal_myobjectcatalog"

When I check the myobject catalog, the data for a new MyObject is there, but its a bit weird. When I go to the ZMI and select portal_myobjcatalog, an instance of MyObject I created said under the 'Type' column that it was 'Unknown'. Also, when I go to the indexes tab and select one of the indexes, there is a link that says ZCTextIndex Lexicon used. The link is incorrect and takes me to a Not Found page.

The main problem I'm having is that the catalog won't reindex the object when its been modified. ReindexObject is called by reindexOnModify, which only triggers if a field has been modified, but the indexes parameter (idxs) is empty and myobject catalog doesn't reindex the object that was modified.

I'm using Plone 5.1 and while s17.person uses grok, I am not using it.

What am I doing wrong that could cause this not to work properly?

ZCTextIndex is likely not the type of index you need, a FieldIndex would be better.

Also, what are your reasons for creating a whole new catalog? Using the default catalog should be sufficient.

1 Like

Thank you for your response.
I did change it to FieldIndex. The link issue I mentioned isn't there anymore.
Unfortunately, when I modify a field and save, it still doesn't reindex.

We're making a catalog because we're essentially trying to make a focused search for MyObject used by a content type that manages MyObjects.

You can get this with the standard catalog. If you want to hide your MyObject CT from the default site search, you can disable it for that. And your custom focused search can use the default catalog.

1 Like

I see. Thank you.
I am curious though why my catalog isn't working though. Are there components that s17 is using that I might not have?

That is not a surprise. In order for an object to reindex itself, it must know in which catalogs it must do the reindex.

The former Archetypes content framework (used by default until Plone 4) had a mixin class CatalogMultiplex which was responsible to perform index operations on all known catalogs. Formerly, Plone used more than a single one: besides the default catalog, there has also been an "uid catalog" and a "reference_catalog" -- all those special purpose catalogs have now been merged into the standard catalog. As far as I know, the Archetypes successor (dexterity) no longer has this mixin class - and therefore, objects only know about the default catalog.

I agree with Thomas that you should be able to realize your requirements with the standard catalog. Otherwise, you will need to enhance your content type that its indexing operations know about more the the default catalog - along the line of the CatalogMixin from Archetypes.

1 Like