class RegistrationForm(Form): name = TextField('name', validators=[Required(), Length(max=300)]) email = TextField('email', validators=[Email(), Required(), Length(max=254)]) password = PasswordField('password', validators=[Required(), Length(min=5, max=300)], widget=PasswordInput(False)) password2 = PasswordField('password2', validators=[ Required(), EqualTo('password', "Passwords must be identical") ], widget=PasswordInput(False)) def validate(self): rv = Form.validate(self) if not rv: return False if User.email_registred(self.email.data): self.email.errors.append('Email already registred!') return False return True
def test_password_input(self, basic_widget_dummy_field): assert 'type="password"' in PasswordInput()(basic_widget_dummy_field) assert 'value=""' in PasswordInput()(basic_widget_dummy_field) assert 'value="foo"' in PasswordInput(hide_value=False)( basic_widget_dummy_field )
class PasswordField(PasswordField): # 修改PasswordInput参数值显示密码 widget = PasswordInput(hide_value=False)
class VisiblePasswordField(PasswordField): widget = PasswordInput(hide_value= False)
class MyPasswordField(PasswordField): ''' custom password field to display ''' widget = PasswordInput(hide_value=False)
class LoginForm(Form): email = TextField('email', validators=[Email(), Required(), Length(max=254)]) password = PasswordField('password', validators=[Required(), Length(min=5, max=300)], widget=PasswordInput(False))
class MyPasswordField(PasswordField): widget = PasswordInput(hide_value=False)