flask web_03

创建用户认证蓝本在abp.py中

在工厂文件中导入 LoginManager

在LoginManager中有一属性为session_protection,可设置为None,basic,strong选择basic,否则关闭浏览器后再打开再按home会登出。



改变表单长度:<div class="col-mg-3">

                                {{wtf.quick_form()}}

                            </div>


如果表单类实现了以validate_开头且后面跟这表单字段名的方法,这个方法会和常规的验证函数一起被调用。

源码如下 :

扫描二维码关注公众号,回复: 4748550 查看本文章

        def validate(self):
        """
        Validates the form by calling `validate` on each field, passing any
        extra `Form.validate_<fieldname>` validators to the field validator.
        """

        extra = {}
        for name in self._fields:
            inline = getattr(self.__class__, 'validate_%s' % name, None)
            if inline is not None:
                extra[name] = [inline]

        return super(Form, self).validate(extra)




    def validate(self, extra_validators=None):
        """
        Validates the form by calling `validate` on each field.

        :param extra_validators:
            If provided, is a dict mapping field names to a sequence of
            callables which will be passed as extra validators to the field's
            `validate` method.

        Returns `True` if no errors occur.
        """
        self._errors = None
        success = True
        for name, field in iteritems(self._fields):
            if extra_validators is not None and name in extra_validators:
                extra = extra_validators[name]
            else:
                extra = tuple()
            if not field.validate(self, extra):
                success = False
        return success

猜你喜欢

转载自blog.csdn.net/CSDN_Gjx/article/details/79312646