Hi,

i think the way to do this is described in:
http://sqlobject.org/Inheritance.html

class Status(InheritableSQLObject):
    # ... general status info

class Sold(Status):
    #... sold-specific info

class OnLoan(Status):
    #... onloan-specific info

class DVD(SQLObject):
    status = ForeignKey("Status")
    # ... special "dvd" data

does this help?

Regards,
Frank

On Thu, Dec 29, 2011 at 15:25, Timo <timomli...@gmail.com> wrote:
>
> 2011/12/29 Petr Jakeš <petr.ja...@tpc.cz>
>>
>>
>>> But your example got me thinking. Is something like the following valid?
>>> (working example)
>>> from sqlobject import *
>>>
>> If it is working, then it is (IMHO) valid :D
>> The DB structure is completely up to you of course. But think twice about
>> the DB model. When the production data is in the database already, it is a
>> pain to change the DB structure.
>
> Hehe, that was what I meant with "valid". I wrote this application about 2
> years ago (without SQLObject), and has become a great mess. So I'm trying to
> start over and do /the right thing/.
>
>>
>>
>>>
>>>
>>>
>>> But then I should handle the inShelve bool value whenever self.sold or
>>> self.onLoan are changed.
>>
>>
>> To keep the logic in the database is up to you. Of course you can
>> automatize it some way (directly in the DB, using DB machinery - computed
>> columns in the Firebird for example, which is IMHO not the best way to go
>> but it works)
>>
>> Or maybe you can try something using:
>
> I think I'm going for the _set_status() and _get_status() approach. Write
> some code which gets and sets the correct table in these methods, so I can
> set/get the status in the program without hassle.
>
> Thanks for your help,
> Timo
>
>>
>>
>> def _set_soldCarefully(self, value):
>>     self.sold = True
>>     self.onLoan = False
>>     self.inShelve = False
>>
>> Regards
>>
>> Petr
>>
>>
>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> 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
>

------------------------------------------------------------------------------
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

Reply via email to