Tutorial
Return to main page
Date: 12/24/09 at 09:59:58
Using the Zope Global Component Registry
Author: chrismDate: 12/24/09 at 09:59:58
By default, repoze.bfg uses a separate Zope Component Architecture *per application*. This is unlike Zope, which tends to use a single ZCA registry for all applications in a single process (each application shares the same "global" registry). This effectively makes it impossible to run more than one Zope application in a single process. Due to this default behavior, many Zope ZCML directives use the zope.component.getGlobalSiteManager API to get "the registry" when they should actually be calling zope.component.getSiteManager (which can be overridden by BFG).
Being able to run more than a single application per process is a goal for BFG, but to emulate Zopelike behavior in repoze.bfg to use Zope software which assumes that there is only a single registry (including ZCML directives), use the following "app" function in your BFG app's run.py. This causes BFG to make use of the global Zope component registry.
1 2 3 4 5 6 7 8 9 10 11 12 | from zope.component import getGlobalSiteManager from repoze.bfg.configuration import Configurator def app(global_settings, **settings): globalreg = getGlobalSiteManager() config = Configurator(registry=globalreg) config.setup_registry(settings=settings) config.hook_zca() config.begin() config.load_zcml('configure.zcml') config.end() return config.make_wsgi_app() |