Hello,

Anyone against this change?

This change is needed because z3c.baseregistry does not work
otherwise. It registers everything in the global registry.
This is a blocker for us to move to ZTK 1.0.

Raise your hands until 28th October midnight UTC.
If noone objects until then, I'll merge to trunk and make a new
release.


This is a forwarded message
From: Adam Groszer <agros...@gmail.com>
To: check...@zope.org
Date: Wednesday, October 27, 2010, 2:25:11 PM
Subject: [Checkins] SVN: zope.component/branches/adamg-fix-getSiteManager/ - 
Fix _api.getSiteManager in the way that it returns now

===8<==============Original message text===============
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.

_______________________________________________
checkins mailing list
check...@zope.org
https://mail.zope.org/mailman/listinfo/checkins

===8<===========End of original message text===========

-- 
Best regards,
 Adam GROSZER                            mailto:agros...@gmail.com

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )

Reply via email to