[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Got a couple more book tests to work. This fix is actually really

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Aug 1 16:15:07 EDT 2005


Log message for revision 37637:
  Got a couple more book tests to work. This fix is actually really 
  important, since it fixes a bug when dealing with local services, which 
  did not work before.
  
  

Changed:
  A   Zope3/trunk/src/zope/app/component/bbb/hooks.py
  U   Zope3/trunk/src/zope/app/component/bbb/localservice.py
  U   Zope3/trunk/src/zope/app/component/hooks.py
  U   Zope3/trunk/src/zope/app/testing/setup.py
  U   Zope3/trunk/src/zope/app/utility/utility.py

-=-
Added: Zope3/trunk/src/zope/app/component/bbb/hooks.py
===================================================================
--- Zope3/trunk/src/zope/app/component/bbb/hooks.py	2005-08-01 20:15:00 UTC (rev 37636)
+++ Zope3/trunk/src/zope/app/component/bbb/hooks.py	2005-08-01 20:15:07 UTC (rev 37637)
@@ -0,0 +1,23 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Hooks BBB
+
+$Id: hooks.py 29143 2005-02-14 22:43:16Z srichter $
+"""
+from zope.component import getSiteManager
+from zope.component.bbb import service
+
+def getServices_hook(context=None):
+    sm = getSiteManager(context)
+    return service.GlobalServiceManager(sitemanager=sm)


Property changes on: Zope3/trunk/src/zope/app/component/bbb/hooks.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: Zope3/trunk/src/zope/app/component/bbb/localservice.py
===================================================================
--- Zope3/trunk/src/zope/app/component/bbb/localservice.py	2005-08-01 20:15:00 UTC (rev 37636)
+++ Zope3/trunk/src/zope/app/component/bbb/localservice.py	2005-08-01 20:15:07 UTC (rev 37637)
@@ -19,3 +19,13 @@
     ('queryNextService', 'getNextService'),
     'The concept of services has been removed. Use utilities instead. '
     'The reference will be gone in X3.3.')
+
+
+def setSite(site=None):
+    from zope.app.component import hooks
+    return hooks.setSite(site)
+
+zope.deprecation.deprecated(
+    'setSite',
+    "`setSite()`'s official location is in `zope.app.component.site`."
+    "The reference will be gone in X3.3.")

Modified: Zope3/trunk/src/zope/app/component/hooks.py
===================================================================
--- Zope3/trunk/src/zope/app/component/hooks.py	2005-08-01 20:15:00 UTC (rev 37636)
+++ Zope3/trunk/src/zope/app/component/hooks.py	2005-08-01 20:15:07 UTC (rev 37637)
@@ -18,6 +18,7 @@
 __docformat__ = 'restructuredtext'
 
 import zope.component
+import zope.deprecation
 import zope.thread
 import zope.security
 
@@ -100,6 +101,11 @@
 def setHooks():
     zope.component.adapter_hook.sethook(adapter_hook)
     zope.component.getSiteManager.sethook(getSiteManager)
+    # Goes away in 3.3.
+    zope.deprecation.__show__.off()
+    from bbb import hooks
+    zope.component.getServices.sethook(hooks.getServices_hook)
+    zope.deprecation.__show__.on()
 
 def resetHooks():
     # Reset hookable functions to original implementation.

Modified: Zope3/trunk/src/zope/app/testing/setup.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/setup.py	2005-08-01 20:15:00 UTC (rev 37636)
+++ Zope3/trunk/src/zope/app/testing/setup.py	2005-08-01 20:15:07 UTC (rev 37637)
@@ -50,6 +50,14 @@
     zapi.traverse(default.registrationManager, key).status = ActiveStatus
     return default[name+suffix]
 
+def createServiceManager(folder, setsite=False):
+    return createSiteManager(folder, setsite)
+
+zope.deprecation.deprecated(
+    'createServiceManager',
+    '`ServiceManager`s became `SiteManager`s. Use `createSiteManager` '
+    'instead. Gone in Zope 3.3.')
+
 #############################################################################
 
 #------------------------------------------------------------------------

Modified: Zope3/trunk/src/zope/app/utility/utility.py
===================================================================
--- Zope3/trunk/src/zope/app/utility/utility.py	2005-08-01 20:15:00 UTC (rev 37636)
+++ Zope3/trunk/src/zope/app/utility/utility.py	2005-08-01 20:15:07 UTC (rev 37637)
@@ -39,8 +39,21 @@
 
 class LocalUtilityService(Persistent, Contained):
     # I really hope noone noone is using this class manually! 
-    pass
+    # ...6 months later: Yes, my book does. :(
 
+    def getUtilitiesFor(self, interface):
+        sm = self.__parent__.__parent__
+        return sm.getUtilitiesFor(interface)
+    
+    def getUtility(self, interface, name=''):
+        sm = self.__parent__.__parent__
+        return sm.queryUtility(interface, name)
+
+    def queryUtility(self, interface, name='', default=None):
+        sm = self.__parent__.__parent__
+        return sm.queryUtility(interface, name, default)
+
+
 deprecated('LocalUtilityService',
            'Services have been removed. Use site manager API. '
            'The reference will be gone in X3.3.')



More information about the Zope3-Checkins mailing list