Commit ed7734d0 authored by Jim Fulton's avatar Jim Fulton

Oops, forgot to check these in when removing the dependency on zope.event

parent 4f75ec10
##############################################################################
#
# Copyright Zope Foundation 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.
#
##############################################################################
def _noop(event):
"""
Tests:
>>> import sys, ZODB.event
>>> notify = ZODB.event
>>> zopemod = sys.modules.get('zope', False)
>>> event = sys.modules.get('zope.event', False)
>>> if event:
... del zopemod.event
... sys.modules['zope.event'] = None
... _ = reload(ZODB.event)
If zope.event isn't installed, then notify is _noop
>>> ZODB.event.notify is ZODB.event._noop
True
If zope.event is installed, then notify is zope.event.notify:
>>> zope = sys.modules['zope'] = type(sys)('zope')
>>> zope.event = sys.modules['zope.event'] = type(sys)('zope.event')
>>> zope.event.notify = lambda e: None
>>> _ = reload(ZODB.event)
>>> ZODB.event.notify is zope.event.notify
True
Cleanup:
>>> if event is False:
... del sys.modules['zope.event']
... else:
... if event:
... zopemod.event = event
... sys.modules['zope.event'] = event
>>> if zopemod is False:
... del sys.modules['zope']
... else:
... sys.modules['zope'] = zopemod
>>> ZODB.event.notify = notify
"""
pass
try:
from zope.event import notify
except ImportError:
notify = _noop
Event support
Sometimes, you want to react when ZODB does certain things. In the
past, ZODB provided ad hoc hook functions for this. Going forward,
ZODB will use an event mechanism. ZODB.event.notify is called with
events of interest.
If zope.event is installed, then ZODB.event.notify is simply an alias
for zope.event. If zope.event isn't installed, then ZODB.event is a
noop.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment