[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Remove zope:hook directive (as suggested by Jim) and moved the hook-up

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Jul 13 19:25:04 EDT 2004


Log message for revision 26514:
  Remove zope:hook directive (as suggested by Jim) and moved the hook-up 
  to Python.
  


Changed:
  U   Zope3/trunk/src/zope/app/component/configure.zcml
  U   Zope3/trunk/src/zope/app/component/hooks.py
  U   Zope3/trunk/src/zope/app/meta.zcml
  D   Zope3/trunk/src/zope/configuration/meta.zcml
  D   Zope3/trunk/src/zope/configuration/metaconfigure.py


-=-
Modified: Zope3/trunk/src/zope/app/component/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/component/configure.zcml	2004-07-13 23:23:17 UTC (rev 26513)
+++ Zope3/trunk/src/zope/app/component/configure.zcml	2004-07-13 23:25:04 UTC (rev 26514)
@@ -32,21 +32,6 @@
       factory="zope.app.utility.vocabulary.UtilityVocabulary"
       interface="zope.interface.interfaces.IInterface" />
 
-  <hook
-      module="zope.component"
-      name="getServices"
-      implementation="zope.app.component.hooks.getServices_hook" />
-
-  <hook
-      module="zope.component"
-      name="adapter_hook"
-      implementation="zope.app.component.hooks.adapter_hook" />
-
-  <hook
-      module="zope.component"
-      name="queryView"
-      implementation="zope.app.component.hooks.queryView" />
-
   <interface interface="zope.interface.Interface" />
 
   <adapter

Modified: Zope3/trunk/src/zope/app/component/hooks.py
===================================================================
--- Zope3/trunk/src/zope/app/component/hooks.py	2004-07-13 23:23:17 UTC (rev 26513)
+++ Zope3/trunk/src/zope/app/component/hooks.py	2004-07-13 23:25:04 UTC (rev 26514)
@@ -15,6 +15,7 @@
 
 $Id$
 """
+import zope.component
 from zope.component import getService
 from zope.component.interfaces import IServiceService
 from zope.app.site.interfaces import ISite
@@ -86,11 +87,18 @@
     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):
@@ -101,3 +109,6 @@
         locate(view, object, name)
 
     return view
+
+# Hook up a new implementation of looking up views.
+zope.component.queryView.sethook(queryView)

Modified: Zope3/trunk/src/zope/app/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/meta.zcml	2004-07-13 23:23:17 UTC (rev 26513)
+++ Zope3/trunk/src/zope/app/meta.zcml	2004-07-13 23:25:04 UTC (rev 26514)
@@ -2,7 +2,6 @@
 
 <!-- Standard configuration directives -->
 <include package="zope.modulealias" file="meta.zcml" />
-<include package="zope.configuration" file="meta.zcml" />
 
 <include package="zope.app.component" file="meta.zcml" />
 <include package="zope.app.publisher" file="meta.zcml" />

Deleted: Zope3/trunk/src/zope/configuration/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/configuration/meta.zcml	2004-07-13 23:23:17 UTC (rev 26513)
+++ Zope3/trunk/src/zope/configuration/meta.zcml	2004-07-13 23:25:04 UTC (rev 26514)
@@ -1,9 +0,0 @@
-<configure xmlns='http://namespaces.zope.org/zope'>
-
-  <!-- zope.configure -->
-  <directives namespace="http://namespaces.zope.org/zope">
-    <directive name="hook" attributes="name implementation module"
-       handler="zope.configuration.metaconfigure.hook" />
-  </directives>
-
-</configure>

Deleted: Zope3/trunk/src/zope/configuration/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/configuration/metaconfigure.py	2004-07-13 23:23:17 UTC (rev 26513)
+++ Zope3/trunk/src/zope/configuration/metaconfigure.py	2004-07-13 23:25:04 UTC (rev 26514)
@@ -1,30 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""
-$Id$
-"""
-
-def hook(_context, name, implementation, module=None):
-    if module:
-        name = "%s.%s" % (module, name)
-    hook = _context.resolve(name)
-    sethook = getattr(hook, 'sethook', None)
-    if sethook is None:
-        raise TypeError(name,'is not hookable')
-    implementation = _context.resolve(implementation)
-    _context.action(
-        discriminator=('http://namespaces.zope.org/zope/hook', name),
-        callable=sethook,
-        args=(implementation, )
-        )



More information about the Zope3-Checkins mailing list