At least if your DB2 is a legacy database you maybe need to define you id
field like this :

Field('legacy_id_field_name','id'),

I think it is a not documented functionality offer to postgres user that
can maybe apply to your situation...

There is also this :

sequence_name='name_of_sequence_in_legacy_database'

Also to solve postgres users problem with sequence created by postgres that
follow a strict pattern... When you create your table with web2py there is
no problem it handle the name of the sequence...

Maybe it could apply and help to solve your problem.

Richard

On Tue, Nov 1, 2011 at 3:02 PM, Richard Vézina
<[email protected]>wrote:

> Hello Omi,
>
> Is this problem have been resolved with the other thread?
>
> Richard
>
>
> On Tue, Nov 1, 2011 at 12:53 PM, Omi Chiba <[email protected]> wrote:
>
>> Tested with MSSQL 2008 and DB2
>>
>> If you connect existing table with primarykey and use writable=False
>> to any of the field on the form, it will show the following error.
>>
>> Traceback (most recent call last):
>>  File "C:\web2py\gluon\restricted.py", line 194, in restricted
>>    exec ccode in environment
>>  File "C:/web2py/applications/otwitter/controllers/default.py", line
>> 91, in <module>
>>  File "C:\web2py\gluon\globals.py", line 149, in <lambda>
>>    self._caller = lambda f: f()
>>  File "C:/web2py/applications/otwitter/controllers/default.py", line
>> 33, in test
>>    if form.process().accepted:
>>  File "C:\web2py\gluon\html.py", line 1950, in process
>>    self.validate(**kwargs)
>>  File "C:\web2py\gluon\html.py", line 1898, in validate
>>    if self.accepts(**kwargs):
>>  File "C:\web2py\gluon\sqlhtml.py", line 1238, in accepts
>>    fields[field.name] = self.record[field.name]
>> TypeError: 'NoneType' object is not subscriptable
>>
>>
>> This is really critical for my project because I cannot use
>> writable=False to the fields I want to protect.
>>
>>
>> Table definition
>> --------------------------------
>> db.define_table('test',
>>    Field('mykey'),
>>    Field('field1'),
>>    Field('field2'),
>>    primarykey=['mykey'],
>>    migrate=False)
>>
>> controller
>> ---------------------------------
>> def test():
>>    db.test.field2.writable=False
>>    form = SQLFORM(db.test)
>>    if form.process().accepted:
>>        response.flash = 'form accepted'
>>    elif form.errors:
>>        response.flash = 'form has errors'
>>    return dict(form=form)
>>
>> view
>> ----------------------------------
>> {{extend 'layout.html'}}
>> <h1>test</h1>
>> {{=form}}
>>
>
>

Reply via email to