[Zope3-Users] Re: NotYet error when creating content during container creation

Alek Kowalczyk thealx at poczta.onet.pl
Wed Feb 28 09:55:21 EST 2007


FB <fbo2 at ...> writes:
 
> It tries that, because it's handler is called by the container's __setitem__
> method. Just write your own - like that:
> 
> class MyContainer(BTreeContainer):
>    def __setitem__(self,key,object)
>       object.__parent__=self
>       object.__name__=key
>       self.__data[key]=object
> 
>    def __delitem__(self,key):
>       del self.__data[key]
> 
> (Not testet!)
> 
> However, you might not need a BTreeContainer but just a simple
> BTrees.OOBTree.OOBtree which behaves like a dict but is a btree.
> 

I don't think I would like to redesign my objects just because the
addIntIdSubscriber does not catch NotYet when getting IKeyReference:

@adapter(ILocation, IObjectAddedEvent)
def addIntIdSubscriber(ob, event):
    # ...
    utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
    if utilities: # assert that there are any utilites
        key = IKeyReference(ob, None) # HERE IS RAISED EXCEPTION
        # ...

Is there a way to override .addIntIdSubscriber in overrides.zcml or another way?
I would write my own version which is more forgiving and does not allow to go
out NotYet raised in IKeyReference adapter.





More information about the Zope3-users mailing list