diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-11-25 18:23:59 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-11-25 18:23:59 +0000 |
| commit | d6b4cdd6254119ab90a18a8b1c2f00daebc7e7ab (patch) | |
| tree | 7e3aedbcf624478b8ced4cf96eb0ad9264b7db7e | |
| parent | 103efb5aae885a70590ad1f3c5807af9da8d1ab7 (diff) | |
| download | pyramid-d6b4cdd6254119ab90a18a8b1c2f00daebc7e7ab.tar.gz pyramid-d6b4cdd6254119ab90a18a8b1c2f00daebc7e7ab.tar.bz2 pyramid-d6b4cdd6254119ab90a18a8b1c2f00daebc7e7ab.zip | |
Don't hook getSiteManager during ZCML load (honor constructor argument only).
| -rw-r--r-- | repoze/bfg/configuration.py | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/repoze/bfg/configuration.py b/repoze/bfg/configuration.py index 0d8469c95..f93e3e754 100644 --- a/repoze/bfg/configuration.py +++ b/repoze/bfg/configuration.py @@ -150,7 +150,6 @@ class Configurator(object): hook_zca=False): self.package = package or caller_package() self.registry = registry - self.hook_zca = hook_zca if registry is None: registry = Registry(self.package.__name__) self.registry = registry @@ -171,6 +170,7 @@ class Configurator(object): self.load_zcml(zcml_file) if hook_zca: getSiteManager.sethook(get_current_registry) + self.registry.zca_hooked = True def _set_settings(self, mapping): settings = Settings(mapping or {}) @@ -315,22 +315,6 @@ class Configurator(object): absolute filename, a relative filename, or a :term:`resource specification`, defaulting to ``configure.zcml`` (relative to the package of the configurator's caller).""" - - # We push our ZCML-defined configuration into an app-local - # component registry in order to allow more than one bfg app - # to live in the same process space without one unnecessarily - # stomping on the other's component registrations (although I - # suspect directives that have side effects are going to - # fail). The only way to do that currently is to override - # zope.component.getGlobalSiteManager for the duration of the - # ZCML includes. We acquire a lock in case another load_zcml - # runs in a different thread simultaneously, in a vain attempt - # to prevent mixing of registrations. There's not much we can - # do about non-load_zcml code that tries to use the global - # site manager API directly in a different thread while we - # hold the lock. Those registrations will end up in our - # application's registry. - package_name, filename = self._split_spec(spec) if package_name is None: # absolute filename package = self.package @@ -341,14 +325,10 @@ class Configurator(object): lock.acquire() manager.push({'registry':self.registry, 'request':None}) try: - getSiteManager.sethook(get_current_registry) - zope.component.getGlobalSiteManager = get_current_registry xmlconfig.file(filename, package, execute=True) finally: - zope.component.getGlobalSiteManager = getGlobalSiteManager lock.release() manager.pop() - getSiteManager.reset() return self.registry def set_security_policies(self, authentication, authorization=None): |
