Re: Migrating to BTrees 4.x

Hanno Schlichting <[email protected]>
Newsgroups gmane.comp.web.zope.zodb
Message-ID <1479589277.2804768.793248889.3547F5CC@webmail.messagingengine.com>
Hey David.



I don't remember the details, but you might have some luck with the
copy_reg module [0].


Usually that only allows you to overwrite the per-type pickle  function
for extension types and not the unpickle one. But IIRC the actual bytes
of a extension type pickle contain something like `copy_reg.__newobj__`
as the actual function to invoke, with the type as an argument. So you
might be able to monkey patch the `__newobj__` function in copy_reg.


Of course this is quite a horrible hack ;-)



Hanno



[0] https://docs.python.org/2/library/copy_reg.html



On Sat, Nov 19, 2016, at 21:21, David Glick wrote:

> I'm working on updating Plone to support ZODB 4 and 5.

> 

> So far most of the blockers are because BTrees 4.x no longer allows
> using keys whose ordering is not well-defined, including None, and
> there are various places where Plone was using None as a key. I
> understand the reason for the restriction and am making progress on
> making Plone no longer do this.
> 

> However I'm looking for suggestions on how to handle migrating
> existing BTrees to remove the None key. Plone users are used to first
> updating the software and then running upgrade steps to make any
> necessary changes to the database. However, because of the new
> restriction, existing BTrees with None as a key cannot be unpickled:
> 

>   File "/Users/davisagli/.buildout/eggs/ZODB-4.4.3-
>   py2.7.egg/ZODB/Connection.py", line 899, in setstate
>     self._setstate(obj, oid)

>   File "/Users/davisagli/.buildout/eggs/ZODB-4.4.3-
>   py2.7.egg/ZODB/Connection.py", line 956, in _setstate
>     self._reader.setGhostState(obj, p)

>   File "/Users/davisagli/.buildout/eggs/ZODB-4.4.3-
>   py2.7.egg/ZODB/serialize.py", line 623, in setGhostState
>     obj.__setstate__(state)

> TypeError: Object has default comparison

> 

> Any ideas about how I can write a migration script to fix these BTree
> instances *after* the BTrees package has been updated? I guess I'm
> looking for a hook to adjust the state for a particular class before
> __setstate__ is called, since BTrees are extension types and I can't
> override __setstate__.
> 

> thanks,

> David

> 



> --

>  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.


-- 
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.