Re: [Zope-dev] Reg. persisting data in ZODB via forms

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.bluebream,gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/09/2011 06:58 AM, Laurence Rowe wrote:

>> > I am not aware of the zcml configuration that can mark a class as
>> > persistent. If you could explain, it would be helpful.
> ZCML is not relevant here.

Correct.  There is no such ZCML directive.  In a ZODB application, all
your "model" classes normally derive from Persistent.

> Deriving your class from Persistent is normally the right choice.
> Storing immutable non-persistent objects such as strings, ints, floats
> or tuples of them also works without surprises. Storing mutable
> non-persistent objects in the ZODB is considered advanced usage and
> you must inform the persistence machinery on any modification. The
> best way to do this is to re-assign the non-persistent object to it's
> parent persistent object, causing the parent to be marked as modified.

FTR, you can also set the parent object's '_p_changed' attribute to a
true value.


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3wz+4ACgkQ+gerLs4ltQ565wCgu7vCM5TihUGsFhhoOYnLkiXK
2c8AoNpLdwn1Sj0m2CWtd9f7l2u1m4Yv
=sG2s
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.