*I'm having quite a strange problem and I really don't know the reason why
it is occurring.
Briefly, my database is storing data of chat rooms, according to different
indexes (by the user who created the chat room, by the chat room ID, etc).

>From the DB root there's an OOBTree with all the kind of indexes. In this
case I'll focus in the index 'IndexByConf' because it's the one I'll use for
the next examples. Inside IndexByConf there's another OOBTree in which the
keys are the conf ID's. For every conf there's another OOBTree which has a
counter to provide ID's for the conferences and, finally!, a OOTreeSet to
store the chatrooms. So if we want to access the OOTreeSet with the list of
the chatrooms for a given conf, we should do* *

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:

What is the problem? Basically, the chat room IS in the OOTreeSet. If you
list the objects in the set you will see that the memory address of the chat
room i'm trying to delete is contained in the set, but the operator in won't
work. Neither won't the method has_key()
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:

<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff646c>

[<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff64ac>,
<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff632c>,
<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff636c>,
<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff63ac>,
<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff646c>,
<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff63ec>,
<MaKaC.plugins.InstantMessaging.handlers.Chatroom object at 0x22ff642c>]

*>>chatroom in root['indexByConf'][confId]['chatrooms']*

*>>chatroom in list(root['indexByConf'][confId]['chatrooms']*)


*>>chatroom in root['indexByConf'][confId]['chatrooms'].keys()*

After this, I switched to a OOBTree instead of a OOTreeSet and I don't get
any exception, but I'd like to avoid using an OOTreeSet in this case.
So do you have any idea of what can be causing this problem?

Best regards,

César Muñoz

Bd. 513, R-042
Tel.: +41 22 76 77159
For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to