[Checkins] SVN: zope.component/branches/adamg-fix-getSiteManager/ - Fix _api.getSiteManager in the way that it returns now
Adam Groszer
agroszer at gmail.com
Wed Oct 27 08:25:11 EDT 2010
Log message for revision 117961:
- Fix _api.getSiteManager in the way that it returns now
globalregistry.getGlobalSiteManager() if context is None. What's anyway
expected according to the docs.
Changed:
U zope.component/branches/adamg-fix-getSiteManager/CHANGES.txt
U zope.component/branches/adamg-fix-getSiteManager/src/zope/component/_api.py
-=-
Modified: zope.component/branches/adamg-fix-getSiteManager/CHANGES.txt
===================================================================
--- zope.component/branches/adamg-fix-getSiteManager/CHANGES.txt 2010-10-27 12:11:58 UTC (rev 117960)
+++ zope.component/branches/adamg-fix-getSiteManager/CHANGES.txt 2010-10-27 12:25:10 UTC (rev 117961)
@@ -4,7 +4,12 @@
3.10.1 (unreleased)
===================
-- Nothing changed yet.
+- Fix _api.getSiteManager in the way that it returns now
+ globalregistry.getGlobalSiteManager() if context is None. What's anyway
+ expected according to the docs.
+ Before it returned a cached local variable (which was init'ed with
+ globalregistry.base). This made z3c.baseregisty burp, because z3c.baseregisty
+ modifies globalregistry.globalSiteManager. Insane.
3.10.0 (2010-09-25)
Modified: zope.component/branches/adamg-fix-getSiteManager/src/zope/component/_api.py
===================================================================
--- zope.component/branches/adamg-fix-getSiteManager/src/zope/component/_api.py 2010-10-27 12:11:58 UTC (rev 117960)
+++ zope.component/branches/adamg-fix-getSiteManager/src/zope/component/_api.py 2010-10-27 12:25:10 UTC (rev 117961)
@@ -39,14 +39,16 @@
# getSiteManager() returns a component registry. Although the term
# "site manager" is deprecated in favor of "component registry",
# the old term is kept around to maintain a stable API.
-base = None
@hookable
def getSiteManager(context=None):
- global base
if context is None:
- if base is None:
- from zope.component.globalregistry import base
- return base
+ # avoid cyclic import
+ # adhere to the doc and return the globalSiteManager,
+ # not some wannabe variable
+ # do not cache the value either, because at least z3c.baseregistry
+ # modifies it
+ from zope.component.globalregistry import getGlobalSiteManager
+ return getGlobalSiteManager()
else:
# Use the global site manager to adapt context to `IComponentLookup`
# to avoid the recursion implied by using a local `getAdapter()` call.
More information about the checkins
mailing list