[Zope-Checkins] SVN: Products.Five/branches/1.4/site/metaconfigure.py * only install the site hook once per class

Rob Miller ra at burningman.com
Tue Nov 28 20:47:04 EST 2006


Log message for revision 71325:
  * only install the site hook once per class
  

Changed:
  U   Products.Five/branches/1.4/site/metaconfigure.py

-=-
Modified: Products.Five/branches/1.4/site/metaconfigure.py
===================================================================
--- Products.Five/branches/1.4/site/metaconfigure.py	2006-11-28 22:46:40 UTC (rev 71324)
+++ Products.Five/branches/1.4/site/metaconfigure.py	2006-11-29 01:47:01 UTC (rev 71325)
@@ -47,7 +47,12 @@
         if not IPossibleSite.implementedBy(site_class):
             raise ConfigurationError('Site class does not implement '
                                      'IPossibleClass: %s' % site_class)
-    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,
@@ -67,6 +72,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