Re: [Zope3-Users] Generating loginForm with formlib
Am Donnerstag, 1. Juni 2006 22:27 schrieb Stephan Richter: > On Thursday 20 April 2006 09:38, Florian Lindner wrote: > > but formlib generates the two fields with name="form.login" therefore the > > session credentials plugin is able to extract the credentials. > > > > How can I use formlib to generate a login form? > > I think we used a custom written form. ;-) But you need to find a way to > turn off the widget prefix. It is probably a matter of overriding the > "setUpWidgets()" method. As you know I've checked in a change to the the session credentials plugin. So this problem has vanished. Regards, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Generating loginForm with formlib
On Thursday 20 April 2006 09:38, Florian Lindner wrote: > but formlib generates the two fields with name="form.login" therefore the > session credentials plugin is able to extract the credentials. > > How can I use formlib to generate a login form? I think we used a custom written form. ;-) But you need to find a way to turn off the widget prefix. It is probably a matter of overriding the "setUpWidgets()" method. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: FW: [Zope3-Users] Generating loginForm with formlib
good call... i like that solution much better. ;) On 4/20/06, Florian Lindner <[EMAIL PROTECTED]> wrote: > Am Donnerstag, 20. April 2006 15:49 schrieb Pete Taylor: > > > -Original Message- > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > > On Behalf Of Florian Lindner > > > Sent: Thursday, April 20, 2006 9:39 AM > > > To: zope3-users@zope.org > > > Subject: [Zope3-Users] Generating loginForm with formlib > > > > > > Hello, > > > I want to generate a login form for the PAU session credentials plugin. > > > The plugin expects a form that have a login and a password field. > > > > > > I've created a interface: > > > > > > class ILoginForm(Interface): > > > """For generating the login form.""" > > > > > > login = TextLine(title=u"Username", > > > required=True) > > > > > > password = Password(title=u"Password", > > > required=True) > > > > > > but formlib generates the two fields with name="form.login" therefore the > > > session credentials plugin is able to extract the credentials. > > > > > > How can I use formlib to generate a login form? > > > the simplest thing to do (or what i ended up doing) was creating a > > credentialsPlugin that provided similar functionality to the standard > > session credentials plugin, but where the standard session credentials > > plugin's extractCredentials method expects to pull 'login' and > > 'password' out of request.get(), you just pull > > request.get('form.login') or something similar. just return the > > credentials dict back out to the principal folder (or whatever > > authenticator you're using) authenticateCredentials method with a dict > > of the form {'login': credentials.getLogin(), 'password': > > credentials.getPassword() } where credentials is a SessionCredentials > > object created from your request.get('form.login') and > > request.get('form.password'). > > > > look at zope.app.authentication.session's design pattern for more. > > Mmhh,, I've also thought about that way. I think it's easier and better to > change the original session credentials plugin to make it selectable in which > fields it looks for the credentials and commit that change back to the > community. > I can do that (I'll ask on zope3-dev for any objections before I commit). > > Regards, > > Florian > -- "All guilt is relative, loyalty counts, and never let your conscience be your guide." - Lucas Buck, American Gothic ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: FW: [Zope3-Users] Generating loginForm with formlib
Am Donnerstag, 20. April 2006 23:50 schrieb Tom Dossis: > >> I want to generate a login form for the PAU session credentials plugin. > >> The plugin expects a form that have a login and a password field. > >> > >> I've created a interface: > >> > >> class ILoginForm(Interface): > >> """For generating the login form.""" > >> > >> login = TextLine(title=u"Username", > >> required=True) > >> > >> password = Password(title=u"Password", > >> required=True) > >> > >> but formlib generates the two fields with name="form.login" therefore > >> the session credentials plugin is able to extract the credentials. > >> > >> How can I use formlib to generate a login form? > >> > >> Thanks, > >> > >> Florian > > > > Hi Florian, > > the simplest thing to do (or what i ended up doing) was creating a > > credentialsPlugin that provided similar functionality to the standard > > session credentials plugin, but where the standard session credentials > > plugin's extractCredentials method expects to pull 'login' and > > 'password' out of request.get(), you just pull > > request.get('form.login') or something similar. just return the > > credentials dict back out to the principal folder (or whatever > > authenticator you're using) authenticateCredentials method with a dict > > of the form {'login': credentials.getLogin(), 'password': > > credentials.getPassword() } where credentials is a SessionCredentials > > object created from your request.get('form.login') and > > request.get('form.password'). > > > > look at zope.app.authentication.session's design pattern for more. > > I reckon the following *should* work, but it doesn't: > >from zope.formlib import form > >class MyLoginForm(form.Form): > prefix='' > form_fields=form.Fields(ILoginForm) > ... > > The problem is the generated form names are '.login' and '.password'. > > IMHO if there's no form/widget prefix, I can't see why there should be a > leading '.' character. > > In the end I patched zope.app.form.Widget.setPrefix() to do what I > expected. That should not be necessary anymore. I habe just modified the session credentials plugin on the trunk (revision 67211). It will also be included in the next release of Zope3. Log message for revision 67211: Change the session credentials plugin to make it configurable in which form fields it looks for the credentials. Regards, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: FW: [Zope3-Users] Generating loginForm with formlib
I want to generate a login form for the PAU session credentials plugin. The plugin expects a form that have a login and a password field. I've created a interface: class ILoginForm(Interface): """For generating the login form.""" login = TextLine(title=u"Username", required=True) password = Password(title=u"Password", required=True) but formlib generates the two fields with name="form.login" therefore the session credentials plugin is able to extract the credentials. How can I use formlib to generate a login form? Thanks, Florian Hi Florian, the simplest thing to do (or what i ended up doing) was creating a credentialsPlugin that provided similar functionality to the standard session credentials plugin, but where the standard session credentials plugin's extractCredentials method expects to pull 'login' and 'password' out of request.get(), you just pull request.get('form.login') or something similar. just return the credentials dict back out to the principal folder (or whatever authenticator you're using) authenticateCredentials method with a dict of the form {'login': credentials.getLogin(), 'password': credentials.getPassword() } where credentials is a SessionCredentials object created from your request.get('form.login') and request.get('form.password'). look at zope.app.authentication.session's design pattern for more. I reckon the following *should* work, but it doesn't: from zope.formlib import form class MyLoginForm(form.Form): prefix='' form_fields=form.Fields(ILoginForm) ... The problem is the generated form names are '.login' and '.password'. IMHO if there's no form/widget prefix, I can't see why there should be a leading '.' character. In the end I patched zope.app.form.Widget.setPrefix() to do what I expected. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: FW: [Zope3-Users] Generating loginForm with formlib
Am Donnerstag, 20. April 2006 15:49 schrieb Pete Taylor: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > On Behalf Of Florian Lindner > > Sent: Thursday, April 20, 2006 9:39 AM > > To: zope3-users@zope.org > > Subject: [Zope3-Users] Generating loginForm with formlib > > > > Hello, > > I want to generate a login form for the PAU session credentials plugin. > > The plugin expects a form that have a login and a password field. > > > > I've created a interface: > > > > class ILoginForm(Interface): > > """For generating the login form.""" > > > > login = TextLine(title=u"Username", > > required=True) > > > > password = Password(title=u"Password", > > required=True) > > > > but formlib generates the two fields with name="form.login" therefore the > > session credentials plugin is able to extract the credentials. > > > > How can I use formlib to generate a login form? > the simplest thing to do (or what i ended up doing) was creating a > credentialsPlugin that provided similar functionality to the standard > session credentials plugin, but where the standard session credentials > plugin's extractCredentials method expects to pull 'login' and > 'password' out of request.get(), you just pull > request.get('form.login') or something similar. just return the > credentials dict back out to the principal folder (or whatever > authenticator you're using) authenticateCredentials method with a dict > of the form {'login': credentials.getLogin(), 'password': > credentials.getPassword() } where credentials is a SessionCredentials > object created from your request.get('form.login') and > request.get('form.password'). > > look at zope.app.authentication.session's design pattern for more. Mmhh,, I've also thought about that way. I think it's easier and better to change the original session credentials plugin to make it selectable in which fields it looks for the credentials and commit that change back to the community. I can do that (I'll ask on zope3-dev for any objections before I commit). Regards, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: FW: [Zope3-Users] Generating loginForm with formlib
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Florian Lindner > Sent: Thursday, April 20, 2006 9:39 AM > To: zope3-users@zope.org > Subject: [Zope3-Users] Generating loginForm with formlib > > Hello, > I want to generate a login form for the PAU session credentials plugin. The > plugin expects a form that have a login and a password field. > > I've created a interface: > > class ILoginForm(Interface): > """For generating the login form.""" > > login = TextLine(title=u"Username", > required=True) > > password = Password(title=u"Password", > required=True) > > but formlib generates the two fields with name="form.login" therefore the > session credentials plugin is able to extract the credentials. > > How can I use formlib to generate a login form? > > Thanks, > > Florian > ___ > Zope3-users mailing list > Zope3-users@zope.org > http://mail.zope.org/mailman/listinfo/zope3-users Hi Florian, the simplest thing to do (or what i ended up doing) was creating a credentialsPlugin that provided similar functionality to the standard session credentials plugin, but where the standard session credentials plugin's extractCredentials method expects to pull 'login' and 'password' out of request.get(), you just pull request.get('form.login') or something similar. just return the credentials dict back out to the principal folder (or whatever authenticator you're using) authenticateCredentials method with a dict of the form {'login': credentials.getLogin(), 'password': credentials.getPassword() } where credentials is a SessionCredentials object created from your request.get('form.login') and request.get('form.password'). look at zope.app.authentication.session's design pattern for more. -- "All guilt is relative, loyalty counts, and never let your conscience be your guide." - Lucas Buck, American Gothic ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Generating loginForm with formlib
Hello, I want to generate a login form for the PAU session credentials plugin. The plugin expects a form that have a login and a password field. I've created a interface: class ILoginForm(Interface): """For generating the login form.""" login = TextLine(title=u"Username", required=True) password = Password(title=u"Password", required=True) but formlib generates the two fields with name="form.login" therefore the session credentials plugin is able to extract the credentials. How can I use formlib to generate a login form? Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users