Duplicate of http://code.google.com/p/web2py/issues/detail?id=648
The error goes away if "unique=True" is removed.

-Mandar

On Monday, August 13, 2012 1:02:55 PM UTC+5:30, Mandar Vaze wrote:
>
> Done. 
> http://code.google.com/p/web2py/issues/detail?id=931
>
> -Mandar
>
> On Saturday, August 11, 2012 2:58:57 AM UTC+5:30, Massimo Di Pierro wrote:
>>
>> Can you please open a ticket?
>>
>> On Wednesday, 8 August 2012 12:08:53 UTC-5, 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