[SQLObject] Serializing SQLObjects (Across Joins) as XML
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Sean M. H. <str...@ma...> - 2004-09-30 22:38:06
|
First, kudos to all SQLObject contributors. I've been using it for just over 24 hours, and I already can't imagine database persistence without it. Second, I am new to the list, but I did search the archives before posting. I only offer this disclaimer because I was surprised by how few messages I saw containing "XML". That being said, I'm looking for a pythonic solution to serialize my SQLObject subclasses as xml. At the single SQLObject level this is trivial--in fact the included __repr__ definition is just a few modifications away from returning a valid xml representation of the object. What's not trivial--for me--is representing the related objects' data. I would like to represent any *-to-many joins for the object as child elements of the original object. For instance, I'd like to have the "xml" property of a Person from the personaddress.py example look like the following: <person id="1" firstName="John" lastName="Doe"> <address id="1" street="123" city="Smallsville" state="IL" zip="50484"/> </person> If I wanted to custom build each object's xml representation by hand that also would be trivial, but I'm trying to abstract this out so all the work is done within a generic super-class (which itself would be a sub-class of SQLObject). So... Q1: If I'm creating a new intermediate class for the purpose of adding the XML serialization features, what is the best abstract way to navigate the one-to-many join data? I see that each SQLObject has a join list and dictionary, but I'm getting lost on interrogating the Join objects to get to the SQLObjects on the other side of the relationship. Q2: Reality check: Is there another xml serialization framework, or even something with SQLObject, that makes what I'm trying to do a waste of time? I've been keeping my eyes open for such an animal for several months, but I haven't seen anything that I think would marry happily with SQLObject. Any help or suggestions would be appreciated. -- Sean M. Hester "Good code is art." |