Alek Kowalczyk wrote:
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)

   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
        # ...

Why not write a custom IKeyReference adapter that doesn't raise the exception? You could even let the adaption fail completely so that the addIntIdSubscriber gets a None for 'key' and doesn't proceed:

def keyReference(obj):
    return None # adaption failed on purpose, don't want key references

-- -- Professional Zope documentation and training
Next Zope 3 training at Camp5:

Zope3-users mailing list

Reply via email to