[Grok-dev] multiple grok wsgi applications possible?

Brandon Craig Rhodes brandon at rhodesmill.org
Wed Dec 17 16:54:54 EST 2008


Chris McDonough <chrism at plope.com> writes:

> It's an excellent idea, but it's also kinda hard.  It means that we'd
> need to supplant the value of
> zope.component.globalregistry.globalRegistry with something that was
> thread local.  Can you *do* this for a module-scope global?  I don't
> think you can?

Well, drat.  I always forget that modules don't support descriptors, so
that ``mymodule.foo`` always consults the module's __dict__ directly,
without any chance of getting in the way and influencing the result.
And since thread-local value-holders do not themselves evaluate to any
useful value, but require you to use attributes on them, we can't make a
module global act thread-local.

For some reason I always expect more symmetry in Python that it actually
offers. :-) My brass-bound Idealism at work, I guess.

> Assuming you can't, it means that you'd need to create an
> implementation of _IGlobalSiteManager that multiplexed for a number of
> registries and you'd nee to create an instance of that as the value of
> zope.component.globalregistry.globalRegistry.
>
> It might be more efficient to just monkey-patch the original definition of
> getGlobalSiteManager as well?

Indeed.

If I were going to use any of the approaches we've discussed, I would
probably run a ``del zope.component.globalregistry.globalRegistry`` so
that any attempts to grab the registry in bits of code I hadn't found
would fail.  As you note, however, there simply might not be any Zope
code that actually consults the `globalregistry` module, so my worries
might be unfounded to begin with.

-- 
Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon


More information about the Grok-dev mailing list