[Tutor] checking for class version info.

Thomas CLive Richards thomi@thomi.imail.net.nz
Thu Jul 3 21:50:01 2003


hmmm.. maybe my email stuffed up. It wouldn't be the first time...

Hey,

I have the following problem:

I have developed a small program which saves (using the pickle module)
some classes, and loads them at a later date. The trouble is, the
program is under active development, and the contents of the classes are
changing constantly. What i would like to do, is invent some way so that
as the classes are loaded, they automatically detect if they are the
save "version" as the current class in the program source file. If they
are not, they somehow "re-initialise" themselves in the new class. does
that make sense?

the first way i thought i would do it is generate some sort of unique
identifier for the source code file each class is in (the code is such
that every class is in a separate file - this cannot be changed); the
size of the file in bytes would probably be enough for this (or perhaps
the last modification time?). However, that would mean that simple
adding a comment to the class would cause the class to reload, and that
wouldn't be too good. 

then i thought about having a variable in each class called "version",
or something similar, so that when a developer updates a class
significantly, he can change the version number, and the classes would
reload themselves, if their version number didn't match that in the
class source code file. The trouble with that is that developers are
lazy, and would probably forget.

Also, i have no idea how to go about doing this "reloading". It may be
that the objects will have to be re-created every time the class
changes, or that I'll have to make a conversion script, but there you
go,

any ideas?

where should i go from here?

thanks,


-- 

Thomi Richards,
thomi@thomi.imail.net.nz