Possible problem with login.kid auto-generated by "tg-admin quickstart ..."

3 views
Skip to first unread message

venkatbo

unread,
Jan 19, 2007, 9:07:57 PM1/19/07
to TurboGears
Hi folks,

I've been having problems adding error/exception handling to a simple
app generated using "tg-admin quickstart ...". I think I have found the
problem, and it appears to do with the snippet:
<input py:for="name,value in original_parameters.items()"
type="hidden" name="${name}" value="${value}"/>
that appears at the bottom of the autogenerated login.kid template...

The steps I followed:
. create a "dapp" project using "tg-admin quickstart",
. no identity
. "index" leads to the blank login page (login.kid)
. login submit triggers "validateuser"
. validation for username/password to include:
. Plain text
. Non-empty
implemented via separate error_handler() and
exception_handler()
. On successfull login validation, takes user to
Welcome page

The login page comes up ok initially. All I have to do is click the
"submit" button repeatedly... The 2nd submit onwards, tg_errors starts
to contain a list of all previous errors- without any of them getting
cleared... between submits.

It appears that the submit button and the hidden values (snippet above
from login.kid) cause the effect of two consecutive submits, even tho
the submit button is clicked only once... taking the valiadation
decorator into a downward spiral... The problem goes away, when I
remove the above snippet from login.kid.

I've pasted the code/changes-to-login.kid/steps at:
http://paste.turbogears.org/paste/877

Unsure if this is to be treated as a bug or not, but if someone tries
to gradually add to autogenerated code (say while learnig TG), they
will encounter this problem... May be the autogenerated login.kid
template should not have the above snippet... The problem is difficult
to narrow down as the runtime tracebacks from the kid-engine are quite
cryptic and not very clear as to the cause of the problem...

Thanks to: Ben Sizer, Diez B. Roggisch and Ian Wilson for helping with
narrowing the problem.
/venkat

vengful...@gmail.com

unread,
Jan 20, 2007, 12:16:17 AM1/20/07
to TurboGears
Hey yeah there are actually I think a few things going wrong. I think
for one thing the usually identiy validator would have removed the
user_name, password and login fields from original_parameters.items()
so they wouldn't be stacking up. Also when you put the text there I
think the css is putting it over the button. If you hit enter or tab
to the button and hit enter the page will still submit even though it
gives off the appearance that you can't click the button. So all in
all that page is meant to be used with the frameworks identity
mechanism and its not a bug it just needs more tweaking to work the way
you want it to. You can adjust it to work with your example as
follows:

Move the line:
<p>${exception}</p>
Outside of the div with id="loginBox" like this.

And then change the line:


<input py:for="name,value in original_parameters.items()"
type="hidden" name="${name}" value="${value}"/>

To this:


<input py:for="name,value in original_parameters.items()"

py:if="name not in ['user_name', 'password', 'login']"


type="hidden" name="${name}" value="${value}"/>

This will prevent the login, user_name and password fields from
stacking up.

-Ian

Reply all
Reply to author
Forward
0 new messages