From 971537afda110d82378d04837ac647a43137f1c7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 20 Jan 2009 23:08:11 +0000 Subject: - Tease out an extra 4% performance boost by changing the Router; instead of using imported ZCA APIs, use the same APIs directly against the registry that is an attribute of the Router. As a result, the registry used by BFG is now a subclass of ``zope.component.registry.Components`` (defined as ``repoze.bfg.registry.Registry``); it has a ``notify`` method. --- repoze/bfg/registry.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'repoze/bfg/registry.py') diff --git a/repoze/bfg/registry.py b/repoze/bfg/registry.py index c62a92a7d..d1dff6744 100644 --- a/repoze/bfg/registry.py +++ b/repoze/bfg/registry.py @@ -3,9 +3,10 @@ import threading import zope.component from zope.component import getGlobalSiteManager +from zope.component import getSiteManager as original_getSiteManager from zope.component.interfaces import ComponentLookupError from zope.component.interfaces import IComponentLookup -from zope.component import getSiteManager as original_getSiteManager +from zope.component.registry import Components from zope.deferredimport import deprecated @@ -23,6 +24,12 @@ deprecated( get_options = "repoze.bfg.settings:get_options", ) +class Registry(Components): + def notify(self, *events): + # iterating over subscribers assures they get executed + for ignored in self.subscribers(events, None): + pass + class ThreadLocalRegistryManager(threading.local): def __init__(self): self.stack = [] @@ -90,9 +97,5 @@ def getSiteManager(context=None): raise ComponentLookupError(*error.args) from zope.testing.cleanup import addCleanUp -try: - addCleanUp(original_getSiteManager.reset) -except AttributeError: - # zope.hookable not yet installed - pass +addCleanUp(original_getSiteManager.reset) # AttributeError: zope.hookable not installed addCleanUp(registry_manager.clear) -- cgit v1.2.3