db.define_table('person',....)
fields=[db.person[key] for key in db.person.fields if key!='id']
fields.append(SQLField('company',....))
db.define_table('employee',*fields)
Let us know if it works.
On Jan 17, 2008, at 11:36 AM, Sharriff wrote:
> Yes I know that, I have used that extensively and it works, but thats
> not what I meant by subclassing(inheritance)
>
> Storm, SQLalchemy e.t.c all support this, a Storm example:
>
> 1 >>> class Person(object):
> 2 ... __storm_table__ = "person"
> 3 ... id = Int(primary=True)
> 4 ... name = Unicode()
>
>
> 1 >>> class Employee(Person):
> 2 ... __storm_table__ = "employee"
> 3 ... company_id = Int()
> 4 ... company = Reference(company_id, Company.id)
> 5 ...
> 6 ... def __init__(self, name):
> 7 ... self.name = name
>
>
>
> Employee is a subclass of "Person"
>
>
> I intend to subclass "Person" to "Parent" and "Child"
>
> Was that clear?
>
> On Jan 17, 2008 4:12 PM, Massimo Di Pierro
> <mdip...@cs.depaul.edu> wrote:
>> Not sure I understand
>>
>> db=SQLDB('....')
>>
>> parent=db.define_table('parent',SQLField
>> ('name2','string',length=20),SQLField('type2','string',lenght=20))
>>
>> then you use db.parent
>>
>> there is no need to import anything. Only SQLDB and SQLField are
>> visible in the scope.
>>
>>
>>
>> On Jan 17, 2008, at 3:48 AM, Sharriff wrote:
>>
>>> Hi Massimo, a quick question:
>>>
>>> Parent = SQLTable('parent',
>>> SQLField('name2', 'string', length = 20),
>>> SQLField('type2', 'string', length = 20)
>>> )
>>>
>>>
>>> What would be the proper "web2py" way to import SQLTable for use? I
>>> dont want to start doing things like "import gluon.sql.SQLTable",
>>> things would then be like Pylons.
>>>
>>>
>>> Thanks
>>
>>