On Jan 25, 2007, at 6:52 PM, Leandro Lucarella wrote:
>
> 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?)
I remember this issue a while ago.... The problem here is that
identity authentication is done in a cp filter, not a tg controller.
TG widgets are designed to validate input in TG's decorator or
manualy in the controller. This means that if you want to use that
form for validation you'll have to patch the identtity filter or an
authentication method of the identity provider, i'm not sure... (I
admit an absolute lack of knowledge regarding identity as I've never
used it in it's current incarnation)
Alberto
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---