Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
serialization and versioning
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Neal Becker  
View profile  
 More options Oct 12 2012, 6:42 am
Newsgroups: comp.lang.python
From: Neal Becker <ndbeck...@gmail.com>
Date: Fri, 12 Oct 2012 06:42:03 -0400
Local: Fri, Oct 12 2012 6:42 am
Subject: serialization and versioning
I wonder if there is a recommended approach to handle this issue.

Suppose objects of a class C are serialized using python standard pickling.  
Later, suppose class C is changed, perhaps by adding a data member and a new
constructor argument.

It would see the pickling protocol does not directly provide for this - but is
there a recommended method?

I could imagine that a class could include a class __version__ property that
might be useful - although I would further expect that it would not have been
defined in the original version of class C (but only as an afterthought when it
became necessary).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Etienne Robillard  
View profile  
 More options Oct 12 2012, 7:04 am
Newsgroups: comp.lang.python
From: Etienne Robillard <animelo...@gmail.com>
Date: Fri, 12 Oct 2012 07:04:37 -0400
Local: Fri, Oct 12 2012 7:04 am
Subject: Re: serialization and versioning
On Fri, 12 Oct 2012 06:42:03 -0400

i guess a easy answer is to say to try python 3.3 but how would this translate in
python (2) code ?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neal Becker  
View profile  
 More options Oct 12 2012, 8:51 am
Newsgroups: comp.lang.python
From: Neal Becker <ndbeck...@gmail.com>
Date: Fri, 12 Oct 2012 08:50:56 -0400
Local: Fri, Oct 12 2012 8:50 am
Subject: Re: serialization and versioning

So are you saying python 3.3 has such a feature?  Where is it described?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Kern  
View profile  
 More options Oct 12 2012, 9:27 am
Newsgroups: comp.lang.python
From: Robert Kern <robert.k...@gmail.com>
Date: Fri, 12 Oct 2012 14:26:19 +0100
Local: Fri, Oct 12 2012 9:26 am
Subject: Re: serialization and versioning
On 10/12/12 11:42 AM, Neal Becker wrote:

> I wonder if there is a recommended approach to handle this issue.

> Suppose objects of a class C are serialized using python standard pickling.
> Later, suppose class C is changed, perhaps by adding a data member and a new
> constructor argument.

> It would see the pickling protocol does not directly provide for this - but is
> there a recommended method?

> I could imagine that a class could include a class __version__ property that
> might be useful - although I would further expect that it would not have been
> defined in the original version of class C (but only as an afterthought when it
> became necessary).

You don't need to add anything to the actual attributes on the class. Just
define your __getstate__() dict to include a '__version__' item. You can treat
the absence of '__version__' in the dict that __setstate__() receives as
implying "version 0".

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dieter Maurer  
View profile  
 More options Oct 13 2012, 2:23 am
Newsgroups: comp.lang.python
From: Dieter Maurer <die...@handshake.de>
Date: Sat, 13 Oct 2012 08:23:14 +0200
Local: Sat, Oct 13 2012 2:23 am
Subject: Re: serialization and versioning

Neal Becker <ndbeck...@gmail.com> writes:
> I wonder if there is a recommended approach to handle this issue.

> Suppose objects of a class C are serialized using python standard pickling.  
> Later, suppose class C is changed, perhaps by adding a data member and a new
> constructor argument.

> It would see the pickling protocol does not directly provide for this - but is
> there a recommended method?

> I could imagine that a class could include a class __version__ property that
> might be useful - although I would further expect that it would not have been
> defined in the original version of class C (but only as an afterthought when it
> became necessary).

The ZODB (Zope Object DataBase) is based on Python's pickle.

In the ZODB world, the following strategy is used:

  *  if the class adds a new data attribute, give it (in addition) a
     corresponding class level attribute acting as "default" value
     in case the pickled state of an instance lacks this
     instance level attribute

  *  for more difficult cases, define an appropriate "__getstate__"
     for the class that handles the necessary model upgrades


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »