[z3-checkins] r18978 - z3/Five/branch/efge-object-event
efge at codespeak.net
efge at codespeak.net
Wed Oct 26 01:51:01 CEST 2005
Author: efge
Date: Wed Oct 26 01:51:01 2005
New Revision: 18978
Modified:
z3/Five/branch/efge-object-event/event.py
z3/Five/branch/efge-object-event/event.zcml
z3/Five/branch/efge-object-event/eventconfigure.py
z3/Five/branch/efge-object-event/fivedirectives.py
Log:
Make <five:containerEvents/> directive work in real life.
Provide proper conflict information. This directive may be given any number
of times, provided the transitional information is always the same.
Modified: z3/Five/branch/efge-object-event/event.py
==============================================================================
--- z3/Five/branch/efge-object-event/event.py (original)
+++ z3/Five/branch/efge-object-event/event.py Wed Oct 26 01:51:01 2005
@@ -121,6 +121,7 @@
FIVE_ORIGINAL_PREFIX = '__five_original_'
+previousConfigInfos = []
containerEventsTransitional = None
containerEventAwareClasses = []
deprecatedManageAddDeleteClasses = []
@@ -619,10 +620,21 @@
from OFS.OrderSupport import OrderSupport
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
-def doMonkies(transitional):
+def doMonkies(transitional, info=None):
"""Monkey patch various methods to provide container events.
+
+ If passed, ``info`` is a zconfig information about where the
+ declaration was made.
"""
global containerEventsTransitional
+ if containerEventsTransitional is not None:
+ if containerEventsTransitional != transitional:
+ from zope.configuration.config import ConfigurationConflictError
+ conflicts = {'five:containerEvents': previousConfigInfos}
+ raise ConfigurationConflictError(conflicts)
+ if info is not None:
+ previousConfigInfos.append(info)
+
containerEventsTransitional = transitional
patchMethod(ObjectManager, '_setObject',
@@ -667,7 +679,10 @@
def undoMonkies():
"""Undo monkey patches.
"""
+ global containerEventsTransitional
for class_, name in _monkied:
killMonkey(class_, name, FIVE_ORIGINAL_PREFIX + name)
+ containerEventsTransitional = None
containerEventAwareClasses[:] = []
deprecatedManageAddDeleteClasses[:] = []
+ previousConfigInfos[:] = []
Modified: z3/Five/branch/efge-object-event/event.zcml
==============================================================================
--- z3/Five/branch/efge-object-event/event.zcml (original)
+++ z3/Five/branch/efge-object-event/event.zcml Wed Oct 26 01:51:01 2005
@@ -1,5 +1,7 @@
<configure xmlns="http://namespaces.zope.org/zope">
+ <include package="zope.app.component" file="meta.zcml" />
+
<adapter
for="OFS.interfaces.IObjectManager"
provides="zope.app.location.interfaces.ISublocations"
Modified: z3/Five/branch/efge-object-event/eventconfigure.py
==============================================================================
--- z3/Five/branch/efge-object-event/eventconfigure.py (original)
+++ z3/Five/branch/efge-object-event/eventconfigure.py Wed Oct 26 01:51:01 2005
@@ -22,8 +22,8 @@
from event import containerEventAwareClasses
from event import deprecatedManageAddDeleteClasses
-def setContainerEvents(transitional):
- doMonkies(transitional)
+def setContainerEvents(transitional, info):
+ doMonkies(transitional, info)
def setContainerEventAware(class_):
"""Instances of the class will receive object events."""
@@ -33,11 +33,14 @@
"""Instances of the class will still see their old methods called."""
deprecatedManageAddDeleteClasses.append(class_)
-def containerEvents(_context, transitional):
+def containerEvents(_context, transitional=False):
+ # Remember context info to be able to provide information
+ # when resolving conflicts about this directive.
+ info = getattr(_context, 'info', '')
_context.action(
- discriminator=('five:containerEvents',),
+ discriminator=None, # conflict resolution is done "by hand"
callable=setContainerEvents,
- args=(transitional,),
+ args=(transitional, info),
)
def containerEventAware(_context, class_):
Modified: z3/Five/branch/efge-object-event/fivedirectives.py
==============================================================================
--- z3/Five/branch/efge-object-event/fivedirectives.py (original)
+++ z3/Five/branch/efge-object-event/fivedirectives.py Wed Oct 26 01:51:01 2005
@@ -72,7 +72,6 @@
transitional = Bool(
title=u"Transitional",
required=False,
- default=False,
)
class IContainerEventAwareDirective(Interface):
More information about the z3-checkins
mailing list