The new web2py (n trunk) has

request.args(0,default=0,cast=int)
On Saturday, 12 May 2012 13:27:07 UTC-5, Najtsirk wrote:
>
> I'm not too good at this stuff...but i think i had similar problem.
>
> In my controller I set the default value for the crud.create reference 
> field:
>
> db.table.referenceid.default = request.args(0)
>
> form=crud.create(db.table)
>
>
> I solved the problem with:
>  
>
>  db.table.referenceid.default = *int*(request.args(0))
>
>
>
>
> On Thursday, 5 April 2012 10:38:38 UTC+2, Sundar wrote:
>>
>> I migrated an application running in 1.94.6 to 1.99.7.
>>
>> I have a peculiar problem. Crud.create on normal tables work. But 
>> whenever I apply crud.create on children table (that is there is a foreign 
>> key in the table; of course, I set a default value for this key before 
>> calling crud.create), I get the error message 
>>
>> <type 'exceptions.KeyError'> '_id'
>> on the line containing the crud.create statement.
>>
>>
>>
>> Do you think I am doing anything wrong?
>>
>> Thanks and regards
>>
>> Sundar
>>
>> ps: If you require the trace, here it is:
>>
>> File "E:/web2py1.99.7Source/applications/rsi_in1/controllers/fs.py" 
>> <http://pc77:8000/admin/default/edit/rsi_in1/controllers/fs.py>, line 492, 
>> in rinvdetadd
>>     form = crud.create(db.fs_reimbinvcovers,next=URL(f='rinvview', 
>> vars=dict(id=id)))
>>   File "E:\web2py1.99.7Source\gluon\tools.py", line 3172, in create
>>     formname=formname,
>>   File "E:\web2py1.99.7Source\gluon\tools.py", line 3089, in update
>>     separator=self.settings.label_separator
>>   File "E:\web2py1.99.7Source\gluon\sqlhtml.py", line 868, in __init__
>>     inp = self.widgets.options.widget(field, default)
>>   File "E:\web2py1.99.7Source\gluon\sqlhtml.py", line 216, in widget
>>     options = requires[0].options()
>>   File "E:\web2py1.99.7Source\gluon\validators.py", line 465, in options
>>     self.build_set()
>>   File "E:\web2py1.99.7Source\gluon\validators.py", line 452, in build_set
>>     records = self.dbset(table).select(*fields, **dd)
>>   File "E:\web2py1.99.7Source\gluon\dal.py", line 7540, in __call__
>>     query = query._id>0
>>   File "E:\web2py1.99.7Source\gluon\dal.py", line 6774, in __getattr__
>>     return self[key]
>>   File "E:\web2py1.99.7Source\gluon\dal.py", line 6714, in __getitem__
>>     return dict.__getitem__(self, str(key))
>> KeyError: '_id'
>>
>>

Reply via email to