actually it's now working, I don't know exactly what was the reason
(I'm using record = db.auth_user(id))

when I output db._lastsql after form.accepts I see that all fields are
updated, not just the password field. How can I change it that only
the password field is updated in the sql statement?

On 17 Sep., 17:54, Alex <[email protected]> wrote:
> I forgot to mention the following: I create the row myself because I
> simply want to change the password:
> id = auth.user_id
> record = Row()
> record.id = id
> record.password = ''
>
> this row is then passed to SQLForm. If I do this instead:
> id = auth.user_id
> record = db.auth_user(id)
> record.password = ''
>
> the form.accepts tries to update all fields. But I would only like to
> update the password field and not modify any other fields.
>
> On 17 Sep., 17:46, Alex <[email protected]> wrote:
>
>
>
> > Hi,
>
> > first of all, many thanks to Massimo and all other contributers.
> > web2py is an amazing framework and exactly what I was looking for.
> > Keep up the excellent work!
>
> > I've got a couple of questions and problems so I'll start with the one
> > which is bugging me the most:
> > I've defined the auth_user table, added username, password and some
> > other fields. So far everything works fine. Now I want to create a
> > form where the user can change the password. In this form I do not
> > want to modify any of the other fields. So I'm doing the following
> > before creating the SQLForm (user_table == db.auth_user):
>
> > for field in user_table.fields:
> >   if field == 'password':
> >     user_table[field].readable = user_table[field].writable = True
> >   else:
> >     user_table[field].readable = user_table[field].writable =
> > False
>
> > this works fine, the form only contains the password field. But when I
> > submit the form, I end up with the following error:
> > File "C:\Tools\web2py_src\gluon\sqlhtml.py", line 1202, in accepts
> >     fields[field.name] = self.record[field.name]
> >   File "C:\Tools\web2py_src\gluon\dal.py", line 3777, in __getitem__
> >     return dict.__getitem__(self, key)
> > KeyError: 'registration_key'
>
> > so its trying to update a field which is writable==False. When I look
> > into the code in sqlhtml.py (line 1200) this is confusing me a little
> > bit:
> > for field in self.table:
> >   if not field.name in fields and field.writable==False:
> >     if record_id:
> >       fields[field.name] = self.record[field.name]
> >     elif self.table[field.name].default!=None:
> >       fields[field.name] = self.table[field.name].default
>
> > why is it checking writable==False? shouldn't it test for
> > writable==True or do I get something wrong here?
>
> > Alex

Reply via email to