I have subscribed to the ObjectAddedEvent for my OrderedContainer.
There is the a strange behavior in the event handler:
- myObj is my contained object
- myObj.__parent__ is my OrderedContainer.

1. this returns True when called in the event handler:
myObj.__name__ in myObj.__parent__
2. this returns False when called in the event handler:
myObj.__name__ in myObj.__parent__.keys()

Code inspection of OrderedContainer.__setitem__ shows the following:
1. first call setitem, which triggers event as side effect
setitem(self, self._data.__setitem__, key, object)

2. after that add key to the _order, which is returned by keys() method:
if not existed:

Is it bug or just works-as-designed? 
I think that this behavior is improper or at least confusing a bit. 
Event should be called *after* 
the keys() method is able to return list with added object, so that:
(myObj.__name__ in myObj.__parent__) == 
(myObj.__name__ in myObj.__parent__.keys())

Zope3-users mailing list

Reply via email to