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