Changeset 15769


Ignore:
Timestamp:
7 Nov 2019, 13:20:25 (5 years ago)
Author:
uli
Message:

Unregister broken event handler on startup.

The indexAdded handler of zope.catalog tries to index all objects in a ZODB
when a new catalog index is added. This means trouble with large catalogs and
we disable this handler on startup. Other ways to unregistering it are more
difficult.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/meta.py

    r8389 r15769  
    3535"""
    3636import grok
     37import grokcore.component
    3738import martian
    3839from grok import components
     
    4041from martian.error import GrokError
    4142from zope import component
     43from zope.processlifetime import IDatabaseOpened
    4244from waeup.kofa.interfaces import IObjectUpgradeEvent
    4345
     
    106108                pass
    107109        #site.logger.info('Catalog `%s` ready.' % self.catalog_name)
     110
     111
     112
     113@grokcore.component.subscribe(IDatabaseOpened)
     114def disable_broken_handlers(event):
     115    """This one is fired after ZODB setup.
     116
     117    Unregsiter handlers etc., that are broken or meant trouble in the past.
     118    """
     119    from zope.component import getGlobalSiteManager
     120    from zope.catalog.catalog import indexAdded
     121    worked = getGlobalSiteManager().unregisterHandler(indexAdded)
     122    if worked:
     123        print("Unregistered handler zope.catalog.catalog.indexAdded")
     124    # TODO: register a replacement that copes better with large indexes.
Note: See TracChangeset for help on using the changeset viewer.