Author: hannosch
Date: Mon Jun 25 14:17:57 2007
New Revision: 44505

Modified:
   kukit/kss.core/trunk/kss/core/kssview.py
Log:
Added the five.lsm conditional code. Part of it is commented as it doesn't seem 
to work :(


Modified: kukit/kss.core/trunk/kss/core/kssview.py
==============================================================================
--- kukit/kss.core/trunk/kss/core/kssview.py    (original)
+++ kukit/kss.core/trunk/kss/core/kssview.py    Mon Jun 25 14:17:57 2007
@@ -41,13 +41,19 @@
 
 from zope import component, interface, event
 from zope.interface.adapter import VerifyingAdapterRegistry
-from zope.component import getSiteManager
 from zope.component.globalregistry import BaseGlobalComponents
-from zope.component.interfaces import IComponentLookup, ComponentLookupError
 from zope.component.interfaces import IObjectEvent
 from zope.app.component.interfaces import ISite
 from zope.app.publication.zopepublication import BeforeTraverseEvent
 
+HAS_FIVE_LSM = True
+try:
+    from five.localsitemanager import registry
+    from zope.component.registry import UtilityRegistration
+except ImportError:
+    HAS_FIVE_LSM = False
+
+
 class SiteViewComponents(BaseGlobalComponents):
 
     def _init_registries(self):
@@ -55,8 +61,21 @@
         # regular AdapterRegistry because it wants to do funny things
         # with __bases__.
         self.adapters = VerifyingAdapterRegistry()
+        # if HAS_FIVE_LSM:
+        #     self.utilities.LookupClass = registry.FiveVerifyingAdapterLookup
+        #     self.utilities._createLookup()
+        #     self.utilities.__parent__ = self
+        # else:
         self.utilities = VerifyingAdapterRegistry()
 
+    if HAS_FIVE_LSM:
+        def registeredUtilities(self):
+            for ((provided, name), (component, info)
+                 ) in self._utility_registrations.iteritems():
+                yield UtilityRegistration(self, provided, name,
+                                          registry._wrap(component, self),
+                                          info)
+
 class SiteView(BrowserView):
     """A browser view that is its own site
     """
@@ -68,6 +87,8 @@
         next = component.getSiteManager()
         self._sitemanager = SiteViewComponents('siteview')
         self._sitemanager.__bases__ = (next, )
+        if HAS_FIVE_LSM:
+            self._sitemanager.__parent__ = self
 
         # On Five, we should wrap it in the acquisition context
         # see, if self has aq_parent, it is done obligatoraly
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to