On Thu, Sep 23, 2010 at 03:54:59PM +0200, César Muñoz wrote: > That said, I'm having some problems when removing a chat room from the > OOTreeSet. Sometimes (and this is weird, sometimes I may get the error, some > others not) I get a KeyError exception when I try to remove the chat room. > This is exactly the line that causes the problem: > * > root['indexByConf'][confId]['chatrooms'].remove(chatroom)* ... > However, if you use the keys() method it will work, and if you use the > operator in with a list of the OOTreeSet it will work also. Take a look at > what I got from the interpreter: > > * > >>chatroom* > <MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff646c>
It sounds as if your Chatroom class doesn't implement comparison
operators (__lt__ and friends) correctly.
If you want to store objects in an OOTreeSet, those objects must
have a well-defined ordering that doesn't change when the objects are
loaded back from the ZODB and end up at a different memory address. The
default comparison provided by Python doesn't cut it.
So: does your Chatroom define __cmp__ or __lt__, __le__, __gt__, __ge__,
__eq__, __ne__ methods?
Marius Gedminas
--
Writing setattr hooks properly is a black art. Writing persistent
setattr hooks is more like hearding bees blindfolded...
-- Casey Duncan
signature.asc
Description: Digital signature
_______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - [email protected] https://mail.zope.org/mailman/listinfo/zodb-dev
