diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-20 23:08:11 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-20 23:08:11 +0000 |
| commit | 971537afda110d82378d04837ac647a43137f1c7 (patch) | |
| tree | 69365f7f1de169ed97f4a215c55ad8c11f1be916 /repoze/bfg/registry.py | |
| parent | be39fa02f8c496461306ec2ce06a2708c377b509 (diff) | |
| download | pyramid-971537afda110d82378d04837ac647a43137f1c7.tar.gz pyramid-971537afda110d82378d04837ac647a43137f1c7.tar.bz2 pyramid-971537afda110d82378d04837ac647a43137f1c7.zip | |
- 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.
Diffstat (limited to 'repoze/bfg/registry.py')
| -rw-r--r-- | repoze/bfg/registry.py | 15 |
1 files changed, 9 insertions, 6 deletions
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) |
