Ok forget this I read to fast you only need to display some information and
not other...

Richard

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

> It look you want some records to not be updatable right? If so... You can
> use permissions like this :
>
>
>
>
> data_entry_person (4), update, tableX, 1
> data_entry_person (4), update, tableX, 3
>
> in Auth_permission table
>
> That's mean data_entry_person or group #4 can update tableX row1 and 3...
>
> When you don't need this granularity (most of the time) you set only once
> update and tableX to 0 so all the records or rows of tableX are allowed to
> be updated...
>
> This can come in nightmare to manage the auth_permission, but at least you
> will be able to make sure a given user is allow or not to update, read,
> select a given rows in a given table...
>
> Richard
>
>
>
> On Tue, Nov 1, 2011 at 4:41 PM, Omi Chiba <[email protected]> wrote:
>
>> >I don't understand what you try to do... You mean you have to show all
>> the >fields?
>> 1. No, I pick some of fields I need from existing table by specifying
>> at model
>> 2. Create/Edit form, I want user to edit some of them but the others
>> should be readonly
>>
>> This will cause error...
>>
>> From your suggestion,
>> I confirmed it's working fine if I create the table with id w/auto
>> increment. Fortunately, my current project allow me to create one. So
>> I will go with this.
>>
>> I will submit a bug report for this.
>>
>>
>> On Nov 1, 3:05 pm, Richard Vézina <[email protected]> wrote:
>> > I don't understand what you try to do... You mean you have to show all
>> the
>> > fields?
>> >
>> > You can just don't tell web2py the field you don't want to show... Just
>> > omit them in your model definition?!
>> >
>> > Since you only read or select your are not don't need writable=false...
>> >
>> > Maybe you don't use the proper tool... SQLFORM is maybe not what you
>> want
>> > to use, or you should have an other look at the doc and pay attention to
>> > the detail about how to use it to mimic the crud.something behavior. We
>> are
>> > supposed to be able to do the exact samething with SQLFORM that we do
>> with
>> > crud and much more... But you can start with crud. There is also
>> > SQLFORM.factory and you can even build your own form with helpers...
>> >
>> > Richard
>> >
>> > On Tue, Nov 1, 2011 at 3:33 PM, Omi Chiba <[email protected]> wrote:
>> > > Richard,
>> >
>> > > Thank you for you suggestion !
>> >
>> > > >Field('legacy_id_field_name','id'),
>> > > I tried this but the same result.
>> >
>> > > > sequence_name='name_of_sequence_in_legacy_database'
>> > > Not sure about it, especially I dont' use any auto increment...
>> >
>> > Yes you don't need this...
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > This problem is critical like I need to suspend my project. Right now
>> > > I only have choice to display all the fields with writable=True, or
>> > > read only.... This is nightmare.
>> >
>> > > On Nov 1, 2:09 pm, Richard Vézina <[email protected]>
>> wrote:
>> > > > 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