Karl Guertin, el 25 de enero a las 10:49 me escribiste:
> 
> On 1/25/07, Leandro Lucarella <[EMAIL PROTECTED]> wrote:
> > What I'm trying to do is a very common and know problem. Using widgets
> > with identity. Nobody have a recipe for that? I think it's a good example
> > to include in quickstarted projects.
> 
> This is not a common problem. Most people authenticate using the
> standard form and work with authenticated people from there. To my
> knowledge, you're the first person to ever ask about it on the mailing
> list.

Wow. I still think is a good example to provide on quickstarted projects
(and I think it encourages people to use widgets, if not even TG uses it
own widgets, who will? ;)

> I think that the following would do the trick:
> 
> form(submit=SubmitButton(name="your_name"), action="XXX", submit_text="Edit")

It worked. What I did was basically add this to login() exposed method:

        if tg_errors:
            flash(_(u'Hubo un error en el formulario!'))

        fields = [
            w.TextField(name='user_name', label=_(u'Username'),
                validator=validators.NotEmpty()),
            w.PasswordField(name='password', validator=validators.NotEmpty())
        ]
        if forward_url:
            fields.append(w.HiddenField(name='forward_url'))
        fields.extend([w.HiddenField(name=name) for name in request.params
             if name not in ('user_name', 'password', 'login', 'forward_url')])
        submit = w.SubmitButton(name='login_submit')
        login_form = w.TableForm(fields=fields, action=previous_url,
                        submit_text=_(u'Ingresar'), submit=submit)
        values = dict(forward_url=forward_url)
        values.update(request.params)
        
        response.status=403
        return dict(login_form=login_form, form_data=values, message=msg,
                logging_in=True)

And replaced the HTML code in login.kid template with:

<p py:content="login_form(value=form_data)">Login Form</p>

Just in case you want to add it to quickstarted projects ;)

But I noticed the validators are not enforced (I can enter an empty
user_name and the one 'catching' the error looks like it's identity, and
no javascript validation is performed, it's that ok?)

-- 
LUCA - Leandro Lucarella - Usando Debian GNU/Linux Sid - GNU Generation
------------------------------------------------------------------------
E-Mail / JID:     [EMAIL PROTECTED]
GPG Fingerprint:  D9E1 4545 0F4B 7928 E82C  375D 4B02 0FE0 B08B 4FB2 
GPG Key:          gpg --keyserver pks.lugmen.org.ar --recv-keys B08B4FB2
------------------------------------------------------------------------
We are born naked, wet and hungry
Then things get worse

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to