Re: Py2 - Py3 Migration

Jim Fulton <[email protected]>
Newsgroups gmane.comp.web.zope.zodb
Message-ID <CAPDm-FhsSZWh37fGV7oaXHJbCGC2FAkRtJ3w3+kZUaNfEtFRuA@mail.gmail.com>
On Fri, Apr 15, 2016 at 2:15 AM, Ramon Navarro Bosch
<[email protected]> wrote:
> Hi everybody!
>
> Is there any script to migrate py2 zodb to py3  ? A script that goes throw
> all transactions and creates a new DB with pickles on python 3 ?

Not that I'm aware of.  Such a script would encounter the same problem
that led to the pickle breakage, which is that in Python 2, it's hard
to know which ordinary strings should be converted to bytes and which
should be converted to unicode.

IMO, before such a conversion, I would introduce a Python 2 bytes type
(a simple subclass of string) and then I'd go through a database and
convert everything that should be bytes to bytes.  Doing this would
likely require application knowledge.  I'd then have the conversion
script convert all bytes to bytes and all other ordinary strings to
unicode.

FWIW, I suspect that converting Zope 3 apps might be easier, since we
made an explicit decision to store all "text" as unicode.  So all
string data should be binary.  A complication to this is that
attribute names would still be strings, so a Zope3-bases converter
would have to be clever enough to recognize attribute names and
convert them, although just converting dictionary keys to unicode
would probably work for most applications.

Jim


P.S. This discussion illustrates something I found a long time ago,
which is that it's best not to be clever with object state. ZODB and
pickle let you override __getstate__ and __setstate__, and I played
with these early on, but it's best to avoid them when possible
to keep thins simple and predictable.

-- 
Jim Fulton
http://jimfulton.info

-- 
You received this message because you are subscribed to the Google Groups "zodb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
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.