Re: Stacking zope.component registries

Marius Gedminas <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <20100409174308.GB4611@platonas>
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

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAku/ZywACgkQkVdEXeem149sqgCfUPkrngtUrJJi62NftNGRpF44
EssAniKVy3QTZv/AA0YAiU6YG1hTJrmS
=lsl6
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.