[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Event - __init__.py:1.1 configure.zcml:1.1 meta.zcml:1.1 metaConfigure.py:1.1

Jim Fulton jim@zope.com
Wed, 18 Dec 2002 18:36:59 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Event
In directory cvs.zope.org:/tmp/cvs-serv25839/lib/python/Zope/App/Event

Added Files:
	__init__.py configure.zcml meta.zcml metaConfigure.py 
Log Message:
Cleaned up after some other checkins.

- Fixed some zcml files that weren't fixed in a refactoring.
  This prevented Zope from starting.

- Renamed some modules that had invalid module names.
  Created some packages for these as well. Moved some tests around
  Fixed up file references to reflect changes.




=== Added File Zope3/lib/python/Zope/App/Event/__init__.py ===
#


=== Added File Zope3/lib/python/Zope/App/Event/configure.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:browser='http://namespaces.zope.org/browser'
>

<serviceType id='Events' 
             interface='Zope.Event.IEventService.' />

<service serviceType='Events'
         component='Zope.Event.GlobalEventService.eventService' />

</zopeConfigure>


=== Added File Zope3/lib/python/Zope/App/Event/meta.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>

  <directives namespace="http://namespaces.zope.org/event">

    <directive name="subscribe" attributes="subscriber event_types filter"
       handler=".metaConfigure.subscribe" />

  </directives>

</zopeConfigure>


=== Added File Zope3/lib/python/Zope/App/Event/metaConfigure.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.
# 
##############################################################################
"""

Revision information:
$Id: metaConfigure.py,v 1.1 2002/12/18 23:36:58 jim Exp $
"""

from Zope.Configuration.Action import Action

from Zope.Event import globalSubscribeMany
from Zope.Event.IEvent import IEvent
from Interface import Interface

counter = 0

def subscribe(_context, subscriber, event_types=(IEvent), filter=None):
    global counter
    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', counter),
             callable = globalSubscribeMany,
             args = (subscriber, event_types, filter)
             ),
        Action(
            discriminator = None,
            callable = globalSubscribeMany,
            args = ('Interfaces', 'provideInterface',
                    type.__module__+'.'+type.__name__, type)
              )      
        ]