[SQLObject] Re: One to many relationships manipulation
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Chris G. <ch...@il...> - 2004-08-16 17:37:43
|
On 16 Aug 2004, Robert Leftwich said:
> I have a requirement to display the data from the 'many' side of a
> relationship (e.g. the addresses in a person-address) in an html table,
> where each column in the html table is one row from the 'many' table
> (i.e. each property of the address object is displayed in a new row of
> the same column).
Hmm... How about adding a __str__() function to the Address class like
this:
class Address(SQLObject):
[... stuff here ...]
def __str__(cls):
return "%(street)s\n%(city)s, %(state)s %(zip)s" % cls.
__dict__
Then, whenever you tried to use an address object as a string, it would
become:
Street
City, State ZIP
And you could just merrily print each Address object! :D
|