Re: Changing and migrating persistence structure

Marius Gedminas <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <20100809110539.GB13638@platonas>
On Mon, Aug 09, 2010 at 09:03:18AM +0800, Martin Aspeli wrote:
> On 8 August 2010 20:29, Hanno Schlichting <[email protected]> wrote:
> 
> > There should be some way of doing this with custom __getstate__ and
> > __setstate__ methods.
> >
> > It's just tricky to get right and a bit fragile. It's much easier to
> > write the migration code if both the old and new class are separate
> > and functioning at the same time.
> 
> The main problem is that the advertised API says you should do:
> 
> from plone.registry import Record
> from plone.registry import field
> 
> registry['foo.bar'] = Record(field.TextLine(), u"my value")
> 
> Here, field.TextLine derives from PersistentField which derives from
> Persistent, and Record derives from Persistent also.
> 
> If I wanted to get rid of the Persistent base, I'd have to make a new
> "tree" of field types (the standard zope.schema ones still need some
> subclassing), and a new Record class with a less obvious name.

You could create the new non-persistent classes with less obvious names
in registry.__setitem__ if you get old-style Persistent values passed in.

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3/BlueBream consulting and development

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkxf4QMACgkQkVdEXeem148QSACeMH4tFRU9ImUzxT5zezYCqpst
o4EAnik1DOkExv/QagwtlotUP92ah+7K
=/uSb
-----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.