On Saturday, August 11, 2012 4:28:24 AM UTC+5:30, Derek wrote:
>
> That definitely looks like a problem. Still though, I think you are taking 
> 3NF a bit too far, no?
>

What I have given below is an example. So it would look i'm taking 3NF too 
far.
But in my real app,  have about 10-15 tables, some of them have just 
"name", some have both "name and description", some have neither.
hence the way I have defined inheritance.

I hope that makes sense.

-Mandar

 

> On Wednesday, August 8, 2012 10:08:53 AM UTC-7, Mandar Vaze wrote:
>>
>> I'm using web2py version : Version 2.0.0 (2012-07-26 06:06:10) dev
>>
>> I have tables defined as follows : 
>>
>> name = db.Table(db, 'name',                                               
>>    
>>         Field('name', 'string', length=128, notnull=True, unique=True))  
>>                                                                             
>> name_desc = db.Table(db, 'base',
>>         name,
>>         Field('description', 'text', default=''))                         
>>       
>> db.define_table('mother', 
>>                 name_desc,        
>>                 format='%(name)s')    
>> db.define_table('father', 
>>                 name_desc,        
>>                 format='%(name)s')    
>> db.define_table('child',                                                 
>>          
>>         name_desc,                                                       
>>        
>>         Field('mother', db.mother),                                       
>>             
>>         Field('father', db.father),                                       
>>                                                    
>>         format='%(name)s')
>>
>> I am able to insert data in "mother" table via script (like 
>> db.mother.insert(name="Alice"))
>> But when I use appadmin to insert new record into mother table, I get the 
>> following error :
>>
>> Traceback (most recent call last):
>>   File "/home/mandar/web2py/gluon/restricted.py", line 205, in restricted
>>     exec ccode in environment
>>   File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
>> line 432, in <module>
>>   File "/home/mandar/web2py/gluon/globals.py", line 182, in <lambda>
>>     self._caller = lambda f: f()
>>   File "/home/mandar/web2py/applications/test1/controllers/appadmin.py", 
>> line 127, in insert
>>     if form.accepts(request.vars, session):
>>   File "/home/mandar/web2py/gluon/sqlhtml.py", line 1146, in accepts
>>     hideerror=hideerror,
>>   File "/home/mandar/web2py/gluon/html.py", line 1870, in accepts
>>     status = self._traverse(status,hideerror)
>>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/home/mandar/web2py/gluon/html.py", line 793, in _traverse
>>     newstatus = c._traverse(status,hideerror) and newstatus
>>   File "/home/mandar/web2py/gluon/html.py", line 800, in _traverse
>>     newstatus = self._validate()
>>   File "/home/mandar/web2py/gluon/html.py", line 1625, in _validate
>>     (value, errors) = validator(value)
>>   File "/home/mandar/web2py/gluon/validators.py", line 554, in __call__
>>     table = self.dbset.db[tablename]
>>   File "/home/mandar/web2py/gluon/dal.py", line 6877, in __getitem__
>>     return dict.__getitem__(self, str(key))
>> KeyError: 'name'
>>
>> Similarly, after populating mother/father and child tables via script 
>> when I try to update "child" record - In the dropdown I see mother's names 
>> instead of ID (as expected) but when I select different "mother" and submit 
>> I get same error (traceback may be slightly different - but same 
>> KeyError:'name' )
>>
>> What is wrong with the table definitions ?
>>
>> Thanks,
>> -Mandar
>>
>>

-- 



Reply via email to