[albatross-users] ctx.req_equals() question.
Michael C. Neel
neel at mediapulse.com
Tue Nov 19 03:05:33 EST 2002
>From the docs, req_equals() returns whether or not the browser request
contains a non-empty field with a name which matches the name argument.
But I've noticed that if you leave a field blank on a form, submit it,
have it return to the same form and submit it again, req_equals will be
true for the empty field.
In my case I have and edit account page to update your account. On the
page is a change password / confirm password set of inputs. If they are
empty I don't want to wipe out the users password, just up date the
contact info. The second submission will however wipe out the password.
To prevent this, my code looks like this:
if ctx.req_equals("password") and ctx.req_equals("confirm"):
if ctx.locals.password == ctx.locals.confirm and
len(ctx.locals.password) != 0:
# change password
It would seem to me that the "and len(ctx.locals.password) != 0" should
not be needed. I don't know if this is intended or not, I could be
missing something about the intended use of req_equals().
Mike
More information about the Albatross-users
mailing list