Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Plone / Zope Component Architecture: Unregister all broken persistent utilities
# -*- coding: utf-8 -*-
from zope.component.hooks import getSite
import logging
log = logging.getLogger(__name__)
def unregister_broken_persistent_components(context):
portal = getSite()
sm = portal.getSiteManager()
for item in sm._utility_registrations.items():
if hasattr(item[1][0], '__Broken_state__'):
# unregisterUtility(component, provided, name)
# See: five.localsitemanager.registry.PersistentComponents.unregisterUtility # noqa"Unregistering component {0}".format(item))
sm.unregisterUtility(item[1][0], item[0][0], item[0][1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.