[Zope-CMF] Saving custom data in a MemberData-object from python
seb bacon
seb@jamkit.com
Mon, 23 Apr 2001 15:58:44 +0100
* Sigve Tjora <sigve@tjora.no> [010423 15:46]:
> I want to store a plain python dictionary, and not just for the
> authenticated user.
>
> If I just store the dictionary in the user object, eg.
>
> user=portal_membership.getAutehnticatedUser()
> user.myData={"id1":"data1", "id2":"data2"}
This code will still work 'just for the authenticated user' - I'm not
sure I get what you are trying to do. Why not make your variable
one of the MemberData properties, as Shane suggested?
Anyway, I thought I'd point out that you must be very careful when
assigning values to mutable sequences such as dictionaries. If you
change such properties in place, your changes won't be registered with
the ZOBD persistence machinery unless you explicitly deal with each
change...for more info, refer to:
http://www.zope.org/Documentation/ZDG/Persistence.dtml
>
> If I do it this way, the userobject "looses" this property when I restart
> Zope. Why is that? How can I store basic python-objects within the
> userobject?
depends on your symptoms, but it could be related to the persistence
issue above.
seb