On Thu, Apr 08, 2010 at 10:15:22PM -0400, Stephan Richter wrote:
On Thursday 08 April 2010, Martin Aspeli wrote:
Right. However, any calls to provideAdapter() and friends would still use the global registry, unless I monkey patch zope.component.globalregistry.base, as would any ZCML directives, I guess.
That's not really monkey patching. :-) I would consider this a valid part of the API. :-)
Then it's _badly-designed_ API. Look at globalregistry.py from zope.component 3.4.0: base = BaseGlobalComponents('base') from zope.testing.cleanup import addCleanUp addCleanUp(lambda: base.__init__('base')) globalSiteManager = base def getGlobalSiteManager(): return globalSiteManager def provideAdapter(factory, adapts=None, provides=None, name=''): base.registerAdapter(factory, adapts, provides, name, event=False) ... There are two names for the same thing: 'base' and 'globalSiteManager'. Different methods use different names. There's an assumption that you can call __init__ on it before and after every test that uses placeless setup. (I hadn't noticed that last part before; I assume it'll override base.__bases__ and destroy any attempts of stacking.) Marius Gedminas -- http://pov.lt/ -- Zope 3 consulting and development