durusmail: durus-users: renaming module/classes problem
renaming module/classes problem
2005-03-15
2005-03-15
2005-03-15
2005-03-15
2005-03-15
renaming module/classes problem
David Binger
2005-03-15
On Mar 15, 2005, at 12:58 PM, Mario Ruggier wrote:

> Hello,
>
> I am trying to move a durus database file to another module, that is
> named differently, and almost identical to original.

Not sure what you mean here.  The database file itself can have any
name.
I think you mean you want to change the names of the classes of the
instances that are stored in that database.  The modules themselves are
not stored in the database.

To change the classes of the instances in the database, you need to
1) unpickle each one with the old class (foo.bar.Baz) available (or
with a temporary fake in sys.modules),
2) assign x.__class__ = new.bar.Baz on each x,
3) call x._p_note_change() on each x, and,
4) last but not least, also call z._p_note_change() on every instance
    z that contains a reference to anything whose class has changed.
5) commit()
6) pack()

Step 6 is optional, but after doing it, you should be able to verify
with
grep that the string 'foo.bar.Baz' is no longer in the database (unless
of
course it is a user's name or something like that).



reply