This was fixed in 1.65.5

On Jul 21, 5:02 pm, Dan <[email protected]> wrote:
> Followup: I got it to work by using the onvalidation parameter in the
> form.accepts() function.
> When there is a blank password, I insert a temporary, bogus password
> into form.vars, and
> then use the onvalidation function to replace that bogus stuff with
> the previous password,
> already in encrypted form.
>
> I'd be interested to know if there is an easier/better way to do this.
>
> On Jul 21, 1:22 pm, Dan <[email protected]> wrote:
>
> > I'm working on a form to let the site administrator edit everything
> > that's part of a user's record in the auth.user table. I want to be
> > able to edit the registration key, reset passwords, etc. This code is
> > almost working, except that when I want to only update the
> > registration key, it also clobbers the password field instead of
> > leaving it alone. I'm surprised, because I expected that if 'password'
> > wasn't defined in the dictionary, that no update would happen to that
> > field.
>
> > Here is how my password field is defined in db.py:
> > db.Field('password', 'password', readable=False, label='Password',
> > requires=[IS_NOT_EMPTY(),CRYPT()]),
>
> > This is the controller code that defines the form and tries to let the
> > administrator leave the password unchanged by leaving the password
> > field blank:
>
> > form=SQLFORM
> > (auth.settings.table_user,user_id,ignore_rw=True,deletable=True)
>
> > if 'password' in request.vars and request.vars['password'] == '' and \
> > IS_NOT_EMPTY in map(type,form.table['password'].requires):
> >     for r in form.table['password'].requires:
> >         if type(r) == IS_NOT_EMPTY:
> >             original_is_not_empty_object = r
> >             form.table['password'].requires.remove(r)
> >     del request.vars['password']
> > else:
> >     original_is_not_empty_object = None
>
> > if form.accepts(request.vars, session, keepvalues=True):
> >     response.flash=T("Form accepted input")
> >     if original_is_not_empty_object:
> >         form.table['password'].requires.append
> > (original_is_not_empty_object)
> >     request.vars.clear()
> > elif form.errors:
> >     response.flash=T("Oops, form is invalid.")
>
> > ----
> > I'm running on GAE, btw - would that handle record updates
> > differently?
>
> > And do I need to replace the IS_NOT_EMPTY() after removing it?
>
> > thanks
> > Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to