[Zope] Re: Problems modifying a "global" attribute of a portal tool.
tseaver at palladion.com
Wed Jul 5 10:09:46 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
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
from persistent.mapping import PersistentMapping
class WhoOnline(SimpleItem, Implicit, PropertyManager):
members_rooms = PersistentMapping()
Tres Seaver +1 202-558-7113 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v188.8.131.52 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Zope