Alek Kowalczyk wrote:
FB <[EMAIL PROTECTED]> 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
        # ...


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:

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


--
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to