Hello all,

Here's what I put in the code of my webapp for debugging purpose.
self.context.subscribers is an OOBTree() (it's the code for a view):

  for k in self.context.subscribers.keys():
    print k
      print self.context.subscribers[k]
    except KeyError:
      print 'Oops!'

And here is the result:

  <gaaz.Members.member.Member object at 0x80e3d72c>
  <gaaz.Members.member.Member object at 0x80e3d62c>
  (datetime.date(2007, 9, 5), True)
  <gaaz.Members.member.Member object at 0x80e3d6ec>
  (datetime.date(2007, 9, 5), True)

The btree has three keys, but one raise a KeyError. Can someone please
explain this mystery ?

Maybe more details will help. I have a persistent class representing
events in a planning. I also want to manage a list of people who want to
participate to these events.

  class Event(Persistent):

    def __init__(self):
      self.subscribers = OOBTree()


The 'subscribers' attribute represents the list. The keys are the
people, the values are a tuple (datetime.date, boolean) representing the
subscription date and if the subscription has been confirmed or not.

This class also has methods for manipulating this 'subscribers'

  def addSubscriber(self, member):
    self.subscribers.update(((member, (datetime.date.today(), False)),))

  def confirmSubscriber(self, member):
    date, old = self.subscribers.get(member) 
    self.subscribers.update(((member, (date, True)),))

  def unconfirmSubscriber(self, member):
    date, old = self.subscribers.get(member) 
    self.subscribers.update(((member, (date, False)),))

  def removeSubscriber(self, member):
    del self.subscribers[member]

Also note that the problem only occurs when I add a new person in some
other container.

Am I doing something wrong ?


Zope3-users mailing list

Reply via email to