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",

    password = Password(title=u"Password",

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?



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

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):

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.

Zope3-users mailing list

Reply via email to