Well, her I am, sorry for the late answer. On Wed, Dec 28, 2011 at 10:30:28PM +0100, Timo wrote: > class DVD(SQLObject): > status = ???? # Should be sold or onloan data > # ... special "dvd" data > > class Sold(SQLObject): > dvd = ForeignKey('DVD') > # ... special "sold" data > > class OnLoan(SQLObject): > dvd = ForeignKey('DVD') > # ... special "on loan" data
1. If you insist on having a separate table for an every status you stuck with a setup that ain't supported by SQL. You can emulate joins using SQLObject but you have to understand once you move operations to the client side you will always have to do all processing on the client side. In that case I recommend to add 2 columns and a calculated attribute: class DVD(SQLObject): status_string = StringCol() status_id = KeyCol() # No, not ForeignKey # Attribute '.status_row' def _get_status_row(self): if self.status_string == 'on loan': return OnLoan.get(self.status_id) elif self.status_string == 'sold': return Sold.get(self.status_id) ...etc... To simplify the code you can create and use a static dict: _status_dict = { 'on loan': OnLoan, 'sold': Sold, } def _get_status_row(self): return self._status_dict[self.status_string].get(self.status_id) 2. If you want to use the power of SQL you have to combine all statuses in one table. For example, make it wide: class Status(SQLObject): dvd = ForeignKey('DVD') # Attributes for status 'on load' ... # Attributes for status 'sold' ... class DVD(SQLObject): status = ForeignKey('DVD') Here you can do SQL-wise joins and filter them on the server side. Oleg. -- Oleg Broytman http://phdru.name/ p...@phdru.name Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss