Hi everyone,

within a python application I can easily model object association with simple references, e.g.:

#################################################################
class FavoritMovies(object):
    def __init__(self, movies):
        self.movies = movies

class Movie(object):
    def __init__(self, name, actor):
        self.name = name
        self.actor = actor

gladiator = Movie("Gladiator", "Russel Crowe")
my_favorit_movies = FavoritMovies([gladiator])

kung_fu_panda = Movie("Kung Fu Panda", "Jack Black")
your_favorit_movies = FavoritMovies([gladiator, kung_fu_panda])
##################################################################

So far, so good. But what is best practise to prepare this data for general persistence? It should be usable for serialisation to xml or storing to an RDBMS or ObjectDatabase ...

I guess I have to incorporate some kind of id for every object and use this as reference with some kind of look-up dictionary, but I wouldn't like it and hope that there're some other sweet pythonic solutions?

Cheers,

Jan
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to