[web2py] Re: crud.create causes an id problem

2012-05-13 Thread Massimo Di Pierro
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 
>>
>>  '_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" 
>> , 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'
>>
>>

[web2py] Re: crud.create causes an id problem

2012-05-12 Thread Najtsirk
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 
>
>  '_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" 
> , 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'
>
>

[web2py] Re: crud.create causes an id problem

2012-04-27 Thread Ross Peoples
I have created Issue 
777: http://code.google.com/p/web2py/issues/detail?id=777

On Friday, April 27, 2012 9:15:07 AM UTC-4, Massimo Di Pierro wrote:
>
> Please open a ticket about this.
>
> On Thursday, 26 April 2012 13:21:34 UTC-5, villas wrote:
>>
>> Just a thought...  if you are trying to create a new table which has a 
>> 'bigint' id,  this may be incompatible if it references an existing table 
>> which has an 'integer' id. 
>>
>> Regards,
>> David
>>
>

[web2py] Re: crud.create causes an id problem

2012-04-27 Thread Massimo Di Pierro
Please open a ticket about this.

On Thursday, 26 April 2012 13:21:34 UTC-5, villas wrote:
>
> Just a thought...  if you are trying to create a new table which has a 
> 'bigint' id,  this may be incompatible if it references an existing table 
> which has an 'integer' id. 
>
> Regards,
> David
>


[web2py] Re: crud.create causes an id problem

2012-04-26 Thread villas
Just a thought...  if you are trying to create a new table which has a 
'bigint' id,  this may be incompatible if it references an existing table 
which has an 'integer' id. 

Regards,
David


[web2py] Re: crud.create causes an id problem

2012-04-26 Thread Ross Peoples
I'm having a similar issue using SQLFORM. I am using a table that stores 
extra data for users, and I call it auth_user_extended:

db.define_table('auth_user_extended',
Field('auth_user', db.auth_user, readable=False, writable=False),
Field('supervisor', 'boolean', label='Is Supervisor?', default=False),
Field('status', 'integer', 
requires=IS_IN_SET(db.auth_user_extended_status_types), default=1, 
notnull=True),
Field('legal_name', length=255, notnull=True),
Field('secondary_email', length=255),
Field('primary_phone', length=20),
Field('secondary_phone', length=20),
Field('start_date', 'datetime'),
Field('end_date', 'datetime'),
Field('barcode_id', length=12, notnull=True, unique=True), 
#requires=IS_NOT_IN_DB(db, 'auth_user_extended.barcode_id')),
Field('alliance_id', length=10, default=None),  # this is the user's 
Alliance ID. If this is None, it defaults to auth_user.username.
Field('supervisor_auth_user', db.auth_user, label='User\'s Supervisor', 
ondelete='NO ACTION'),
Field('assistant_to_auth_user', db.auth_user, label='Assistant To 
User', ondelete='NO ACTION'),
Field('vacation_minutes', 'decimal(10,2)', default=0, 
requires=IS_NOT_EMPTY(), notnull=True),
Field('personal_minutes', 'decimal(10,2)', default=0, 
requires=IS_NOT_EMPTY(), notnull=True),
Field('sick_minutes', 'decimal(10,2)', default=0, 
requires=IS_NOT_EMPTY(), notnull=True),
Field('holiday_minutes', 'decimal(10,2)', default=None),   # setting 
this field to None makes it default to the holiday's holiday_minutes setting
Field('picture', 'upload', 
uploadfolder=os.path.join(request.folder,'static/images/user-pictures'))
)

I'm trying to use this code:

form = SQLFORM(db.auth_user, row.auth_user)
form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended))

But I've also tried making a form for auth_user_extended by itself and I 
still get the same problem:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.

Traceback (most recent call last):
  File "/var/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/var/web2py/applications/bonfire/controllers/administration.py" 
, line 
292, in 
  File "/var/web2py/gluon/globals.py", line 175, in 
self._caller = lambda f: f()
  File "applications/bonfire/modules/core.py", line 473, in f
return action(*a, **b)
  File "/var/web2py/applications/bonfire/controllers/administration.py" 
, line 
286, in users
return update()
  File "/var/web2py/applications/bonfire/controllers/administration.py" 
, line 
232, in update
form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended))
  File "/var/web2py/gluon/sqlhtml.py", line 888, in __init__
inp = self.widgets.options.widget(field, default)
  File "/var/web2py/gluon/sqlhtml.py", line 218, in widget
options = requires[0].options()
  File "/var/web2py/gluon/validators.py", line 471, in options
self.build_set()
  File "/var/web2py/gluon/validators.py", line 458, in build_set
records = self.dbset(table).select(*fields, **dd)
  File "/var/web2py/gluon/dal.py", line 8004, in __call__
query = query._id>0
  File "/var/web2py/gluon/dal.py", line 7165, in __getattr__
return self[key]
  File "/var/web2py/gluon/dal.py", line 7105, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: '_id'


I just updated to the latest trunk and started having this issue.



[web2py] Re: crud.create causes an id problem

2012-04-05 Thread Massimo Di Pierro
Please open a bug report this on googlecode.

On Thursday, 5 April 2012 03:38:38 UTC-5, 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 
>
>  '_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" 
> , 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'
>
>