[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Finally fixed the hooks mess. It now behaves correctly and all tests

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Jul 14 14:17:08 EDT 2004


Log message for revision 26533:
  Finally fixed the hooks mess. It now behaves correctly and all tests 
  pass. Sorry about that.
  


Changed:
  U   Zope3/trunk/src/zope/app/appsetup/appsetup.py
  U   Zope3/trunk/src/zope/app/component/hooks.py
  U   Zope3/trunk/src/zope/app/tests/setup.py


-=-
Modified: Zope3/trunk/src/zope/app/appsetup/appsetup.py
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/appsetup.py	2004-07-14 18:01:33 UTC (rev 26532)
+++ Zope3/trunk/src/zope/app/appsetup/appsetup.py	2004-07-14 18:17:07 UTC (rev 26533)
@@ -16,6 +16,7 @@
 $Id$
 """
 import zope.interface
+import zope.app.component.hooks
 from zope.security.interfaces import IParticipation
 from zope.security.management import system_user
 
@@ -58,6 +59,9 @@
     from zope.security.management import newInteraction
     newInteraction(SystemConfigurationParticipation())
 
+    # Hook up custom component architecture calls
+    zope.app.component.hooks.setHooks()
+
     # Load server-independent site config
     context = xmlconfig.file(file, execute=execute)
 
@@ -67,6 +71,7 @@
 
     _configured = execute
 
+
     return context
 
 def database(db):

Modified: Zope3/trunk/src/zope/app/component/hooks.py
===================================================================
--- Zope3/trunk/src/zope/app/component/hooks.py	2004-07-14 18:01:33 UTC (rev 26532)
+++ Zope3/trunk/src/zope/app/component/hooks.py	2004-07-14 18:17:07 UTC (rev 26533)
@@ -87,18 +87,11 @@
     except ComponentLookupError:
         return serviceManager
 
-# Hook up a new implementation of looking up services.
-zope.component.getServices.sethook(getServices_hook)
-
 def adapter_hook(interface, object, name='', default=None):
     try:
         return siteinfo.adapter_hook(interface, object, name, default)
     except ComponentLookupError:
         return default
-
-# Hook up a new implementation of looking up adapters.
-zope.component.adapter_hook.sethook(adapter_hook)
-
     
 def queryView(object, name, request, default=None,
               providing=Interface, context=None):
@@ -110,5 +103,16 @@
 
     return view
 
-# Hook up a new implementation of looking up views.
-zope.component.queryView.sethook(queryView)
+
+def setHooks():
+    # Hook up a new implementation of looking up views.
+    zope.component.getServices.sethook(getServices_hook)
+    zope.component.adapter_hook.sethook(adapter_hook)
+    zope.component.queryView.sethook(queryView)
+
+def resetHooks():
+    # Reset hookable functions to original implementation.
+    zope.component.getServices.reset()
+    zope.component.adapter_hook.reset()
+    zope.component.queryView.reset()
+    

Modified: Zope3/trunk/src/zope/app/tests/setup.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/setup.py	2004-07-14 18:01:33 UTC (rev 26532)
+++ Zope3/trunk/src/zope/app/tests/setup.py	2004-07-14 18:17:07 UTC (rev 26533)
@@ -89,10 +89,12 @@
 
 #------------------------------------------------------------------------
 # Placeful setup
+import zope.app.component.hooks
 from zope.app.tests.placelesssetup import setUp as placelessSetUp
 from zope.app.tests.placelesssetup import tearDown as placelessTearDown
 def placefulSetUp(site=False):
     placelessSetUp()
+    zope.app.component.hooks.setHooks()
     setUpAnnotations()
     setUpDependable()
     setUpTraversal()
@@ -107,6 +109,7 @@
 from zope.app.component.hooks import setSite
 def placefulTearDown():
     placelessTearDown()
+    zope.app.component.hooks.resetHooks()
     setSite()
 
 



More information about the Zope3-Checkins mailing list