[Zope3-checkins] CVS: Zope3/src/zope/configuration - meta.zcml:1.3 metaconfigure.py:1.3 hookregistry.py:NONE
Jim Fulton
jim@zope.com
Sun, 18 May 2003 14:07:15 -0400
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv11328/src/zope/configuration
Modified Files:
meta.zcml metaconfigure.py
Removed Files:
hookregistry.py
Log Message:
Updated hook configuration to use the new hooking machinery.
Also simplified hook zcml configuration. It is no longer necessary to
declare that something is hookable before hooking it. After all, we
can now introspect objects to determine if they are hookable.
=== Zope3/src/zope/configuration/meta.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/meta.zcml:1.2 Wed Dec 25 09:13:33 2002
+++ Zope3/src/zope/configuration/meta.zcml Sun May 18 14:06:44 2003
@@ -2,10 +2,8 @@
<!-- zope.configure -->
<directives namespace="http://namespaces.zope.org/zope">
- <directive name="hookable" attributes="name module"
- handler="zope.configuration.metaconfigure.provideHookable" />
<directive name="hook" attributes="name implementation module"
- handler="zope.configuration.metaconfigure.provideHook" />
+ handler="zope.configuration.metaconfigure.hook" />
</directives>
</zopeConfigure>
=== Zope3/src/zope/configuration/metaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/configuration/metaconfigure.py:1.2 Wed Dec 25 09:13:33 2002
+++ Zope3/src/zope/configuration/metaconfigure.py Sun May 18 14:06:44 2003
@@ -15,38 +15,19 @@
$Id$
"""
from zope.configuration.action import Action
-from zope.configuration.hookregistry import HookRegistry
-# one could make hookRegistry a service and
-# theoretically use it TTW, but that doesn't immediately seem like a
-# great idea
-hookRegistry = HookRegistry()
-
-addHookable = hookRegistry.addHookable
-addHook = hookRegistry.addHook
-
-def provideHookable(_context, name, module=None):
- if module:
- name = "%s.%s" % (module, name)
- name = _context.getNormalizedName(name)
- return [
- Action(
- discriminator=('addHookable', name),
- callable=addHookable,
- args=(name,)
- )
- ]
-
-
-def provideHook(_context, name, implementation, module=None):
+def hook(_context, name, implementation, module=None):
if module:
name = "%s.%s" % (module, name)
- name = _context.getNormalizedName(name)
- implementation = _context.getNormalizedName(implementation)
+ hook = _context.resolve(name)
+ sethook = getattr(hook, 'sethook', None)
+ if sethook is None:
+ raise TypeError(name,'is not hookable')
+ implementation = _context.resolve(implementation)
return [
Action(
- discriminator=('addHook', name),
- callable=addHook,
- args=(name, implementation)
+ discriminator=('http://namespaces.zope.org/zope/hook', name),
+ callable=sethook,
+ args=(implementation, )
)
]
=== Removed File Zope3/src/zope/configuration/hookregistry.py ===