[Tutor] How to model objects aimed to persistence?
Alan Gauld
alan.gauld at btinternet.com
Thu Jun 17 19:14:16 CEST 2010
"Knacktus" <knacktus at googlemail.com> wrote
###########################################################################
> my_favourite_movies = FavouriteMovies([Movie("Gladiator", "Russel
> Crowe")])
> ###########################################################################
>
> When I want to rebuild the data from a xml file or database, my
> objects somehow need to know which references to other objects they
> hold.
OK, If you limit yourself to XML or a database then yes you will
need an ID and use the IDs as references. Thats why Pickle/Shelve
are so convenient for persistence - they don;t need the references,
you can just pickle the list of objects, or whatever.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list