Hash: SHA1

JoseLuis de la Rosa TriviƱo wrote:

> I'm working with zope 2.9.1 in debug mode.
> I have a tool (especifically who_online) where I have created a new
> class attribute and some methods to modify an read it. A python script
> is called with a user's click and uses those methods.
> > 
> My problem is that some times when a user modifies the value of the
> attribute (a python dicctionary) the action takes no effect or it takes
> effect only in the current transaction. I'm still newbie in zope.
> The class attribute is called "members_rooms" and the methods are:
> def joinedRoom(self, member, room):
>         """
>             Adds the member to the room's list of members.
>         """
>         self.members_rooms[member] = room
>         logger.info(" %s joined room %s ", member, room)
> def leftRoom(self, member, room):
>         """
>             Removes the member from the room where it's supposed
>             to be joined. 
>         """
>         if self.members_rooms.has_key(member):
>             del self.members_rooms[member]
>             logger.info(" %s left the room %s ", member, room)
> I get log info messages correctly and if I print the value of
> members_rooms before and after the statement (del or assignment) printed
> values are correct, but when I query the value of the attribute from a
> python script just after the "transaction" has finished, the attribute's
> value has not changed.
> May some body help me? What am I doing wrong?
> WhoOnline is a class (and portal tool) that inherits from SimpleItem,
> Implicit and PropertyManager.

Make your 'members_rooms' attribute a PersistentMapping, instead of a
dict, e.g.:

   from persistent.mapping import PersistentMapping

   class WhoOnline(SimpleItem, Implicit, PropertyManager):
         members_rooms = PersistentMapping()

- --
Tres Seaver          +1 202-558-7113          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to