[Zope3-checkins] CVS: Zope3/src/zope/app/event - metaconfigure.py:1.4 metadirectives.py:1.1 globalservice.py:1.12 meta.zcml:1.4

Philipp von Weitershausen philikon at philikon.de
Sun Aug 3 18:56:46 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/event
In directory cvs.zope.org:/tmp/cvs-serv19977

Modified Files:
	globalservice.py meta.zcml 
Added Files:
	metaconfigure.py metadirectives.py 
Log Message:
Converted yet another set of ZCML directives.


=== Zope3/src/zope/app/event/metaconfigure.py 1.3 => 1.4 ===
--- /dev/null	Sun Aug  3 17:56:44 2003
+++ Zope3/src/zope/app/event/metaconfigure.py	Sun Aug  3 17:56:10 2003
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# 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.0 (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$
+"""
+
+from zope.app.interfaces.event import IEvent
+from globalservice import globalSubscribeMany
+
+directive_counter = 0
+def subscribe(_context, subscriber, event_types=[IEvent], filter=None):
+    global directive_counter
+    directive_counter += 1
+
+    _context.action(
+        # subscriptions can never conflict
+        discriminator = ('subscribe', directive_counter),
+        callable = globalSubscribeMany,
+        args = (subscriber, event_types, filter)
+        )


=== Added File Zope3/src/zope/app/event/metadirectives.py ===
##############################################################################
#
# 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.0 (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: metadirectives.py,v 1.1 2003/08/03 21:56:10 philikon Exp $
"""

from zope.interface import Interface
from zope.configuration.fields import GlobalObject, Tokens
from zope.schema import TextLine

class ISubscribeDirective(Interface):
    """
    Subscribe to events
    """

    subscriber = GlobalObject(
        title=u"Subscriber",
        required=True
        )

    event_types = Tokens(
        title=u"Events to subscribe to",
        description=u"Defaults to IEvent",
        required=False,
        value_type = GlobalObject()
        )

    filter = GlobalObject(
        title=u"Filter",
        required=False
        )


=== Zope3/src/zope/app/event/globalservice.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/event/globalservice.py:1.11	Mon Jun 30 13:50:28 2003
+++ Zope3/src/zope/app/event/globalservice.py	Sun Aug  3 17:56:10 2003
@@ -12,8 +12,6 @@
 # 
 ##############################################################################
 """
-
-Revision information:
 $Id$
 """
 
@@ -28,8 +26,6 @@
 from zope.app.interfaces.event import IEvent, ISubscriber, ISubscribingAware
 from zope.app.interfaces.event import IGlobalSubscribable, IPublisher
 
-from zope.configuration.action import Action
-
 import logging
 import pprint
 from StringIO import StringIO
@@ -40,31 +36,6 @@
         or event_type.extends(IEvent, strict=False)
         ):
         raise TypeError('event_type must extend IEvent: %s' % repr(event_type))
-
-directive_counter = 0
-def subscribeDirective(_context, subscriber,
-                       event_types=(IEvent,), filter=None):
-    global directive_counter
-    directive_counter += 1
-
-    subscriber = _context.resolve(subscriber)
-
-    event_type_names = event_types
-    event_types=[]
-    for event_type_name in event_type_names.split():
-        event_types.append(_context.resolve(event_type_name))
-
-    if filter is not None:
-        filter = _context.resolve(filter)
-
-    return [
-        Action(
-             # subscriptions can never conflict
-             discriminator = ('subscribe', directive_counter),
-             callable = globalSubscribeMany,
-             args = (subscriber, event_types, filter)
-             )
-        ]
 
 class Logger:
     """Class to log all events sent out by an event service.


=== Zope3/src/zope/app/event/meta.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/event/meta.zcml:1.3	Mon Dec 30 09:03:02 2002
+++ Zope3/src/zope/app/event/meta.zcml	Sun Aug  3 17:56:10 2003
@@ -1,10 +1,16 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+<configure
+    xmlns='http://namespaces.zope.org/zope'
+    xmlns:meta="http://namespaces.zope.org/meta"
+    >
 
-  <directives namespace="http://namespaces.zope.org/event">
+  <meta:directives namespace="http://namespaces.zope.org/event">
 
-    <directive name="subscribe" attributes="subscriber event_types filter"
-       handler="zope.app.event.globalservice.subscribeDirective" />
+    <meta:directive
+        name="subscribe"
+        schema=".metadirectives.ISubscribeDirective"
+        handler=".metaconfigure.subscribe"
+        />
 
-  </directives>
+  </meta:directives>
 
-</zopeConfigure>
+</configure>




More information about the Zope3-Checkins mailing list