durusmail: durus-users: Durus Change Preview
Durus Change Preview
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-25
2006-10-31
2006-10-31
Durus Change Preview
David Binger
2006-10-25
On Oct 25, 2006, at 4:30 PM, David Binger wrote:

> It isn't impossible to change the class of the root after this
> change.  It is just that the recipe for doing it is a bit longer,
> and the same goes for changing the class of any persistent instance
> that uses data for slots.

I think this recipe works, slots or not:


"""
Example script for changing the root class.
"""
from durus.connection import Connection
from durus.file_storage import FileStorage
from durus.persistent import Persistent
import durus.persistent_dict

# Edit these as you like.
storage_file_name = "foo.durus"
new_class_for_root = Persistent

if __name__ == '__main__':
     # Set the class before the instance is created or loaded,
     # so that we avoid possible slot layout obstacles.
     durus.persistent_dict.PersistentDict = new_class_for_root
     connection = Connection(FileStorage(storage_file_name"))
     connection.get_root()._p_note_change()
     connection.commit()

reply