[Zope-Checkins] SVN: Products.Five/trunk/ * don't barf w/ multiple localsite declarations on the same class

Rob Miller ra at burningman.com
Thu Nov 30 17:30:04 EST 2006


Log message for revision 71343:
  * don't barf w/ multiple localsite declarations on the same class
  

Changed:
  U   Products.Five/trunk/CHANGES.txt
  U   Products.Five/trunk/site/metaconfigure.py

-=-
Modified: Products.Five/trunk/CHANGES.txt
===================================================================
--- Products.Five/trunk/CHANGES.txt	2006-11-30 22:18:48 UTC (rev 71342)
+++ Products.Five/trunk/CHANGES.txt	2006-11-30 22:30:03 UTC (rev 71343)
@@ -11,6 +11,10 @@
 * Port code from Zope 3 making resource directories recursive.
   Thanks to Richard Waid.
 
+* site/metaconfigure: Local site hook now only applied once per class, so
+  multiple <five:localsite> tags for the same class won't cause config
+  errors.
+
 Five 1.5.2 (unreleased)
 =======================
 

Modified: Products.Five/trunk/site/metaconfigure.py
===================================================================
--- Products.Five/trunk/site/metaconfigure.py	2006-11-30 22:18:48 UTC (rev 71342)
+++ Products.Five/trunk/site/metaconfigure.py	2006-11-30 22:30:03 UTC (rev 71343)
@@ -40,7 +40,11 @@
                            "See Five/doc/localsite.txt .",
                            DeprecationWarning, 
                            _context.info.file, _context.info.line)
-    if site_class is not None:
+    # only install the hook once
+    already = getattr(class_, '_localsite_marker', False)
+
+    if site_class is not None and not already:
+        class_._localsite_marker = True
         _context.action(
             discriminator = (class_,),
             callable = classSiteHook,
@@ -61,6 +65,8 @@
         delattr(class_, 'getSiteManager')
         delattr(class_, 'setSiteManager')
         classImplementsOnly(class_, implementedBy(class_)-IPossibleSite)
+        if getattr(class_, '_localsite_marker', False):
+            delattr(class_, '_localsite_marker')
 
 from zope.testing.cleanup import addCleanUp
 addCleanUp(uninstallSiteHooks)



More information about the Zope-Checkins mailing list