c.w.p.PasswordChangeWidget(PasswordWidget) : class documentation

Part of canonical.widgets.password View In Hierarchy

Implements interfaces: canonical.launchpad.webapp.interfaces.IMultiLineWidgetLayout, zope.app.form.browser.interfaces.ITextBrowserWidget

A password change widget.

Text is not echoed to the user, and two text boxes are used to ensure the password is entered correctly.

Method hasInput We always have input if there is an existing value
Method getInputValue Ensure both text boxes contain the same value and inherited checks
Method _getCurrentPassword Undocumented
def hasInput(self):
We always have input if there is an existing value

No input indicates unchanged.

def _getCurrentPassword(self):
Undocumented
def getInputValue(self):

Ensure both text boxes contain the same value and inherited checks

>>> from canonical.launchpad.webapp.servers import (
...     LaunchpadTestRequest)
>>> from zope.schema import Field
>>> field = Field(__name__='foo', title=u'Foo')

The widget will only return a value if both of the text boxes contain the same value. It returns the value encrypted.

>>> request = LaunchpadTestRequest(form={
...     'field.foo': u'My Password', 'field.foo_dupe': u'My Password'})
>>> widget = PasswordChangeWidget(field, request)
>>> crypted_pw = widget.getInputValue()
>>> encryptor = getUtility(IPasswordEncryptor)
>>> encryptor.validate(u'My Password', crypted_pw)
True

Otherwise it raises the exception required by IInputWidget

>>> request = LaunchpadTestRequest(form={
...     'field.foo': u'My Password', 'field.foo_dupe': u'No Match'})
>>> widget = PasswordChangeWidget(field, request)
>>> widget.getInputValue()
Traceback (most recent call last):
    [...]
WidgetInputError: ('foo', u'Foo', u'Passwords do not match.')
API Documentation for Launchpad, generated by pydoctor at 2010-09-27 00:00:11.