[Zope-dev] Stacking zope.component registries
Martin Aspeli
optilude+lists at gmail.com
Thu Apr 8 13:26:59 EDT 2010
Hi,
I'd like to come up with a way to set up a test fixture that does the
component registry equivalent of stackable DemoStorage's: whilst a layer
is in effect, calls to provideAdapter() and friends (and ZCML execution)
go into a global registry that is stacked on top of the default global one.
On layer tear-down, the registry is popped, leaving the original (or
previous) global registry intact.
In zope.component.globalregistry, I see:
def provideUtility(component, provides=None, name=u''):
base.registerUtility(component, provides, name, event=False)
base is a module-level variable of type BaseGlobalComponents(). I guess
there'd be a way to use __bases__ to create this kind of stack, but I'm
not clear on the details, and in particular whether this would really
work with provideAdapter() and the rest of the (test-oriented) Python API.
Martin
More information about the Zope-Dev
mailing list