本文整理汇总了Python中karesansui.lib.checker.Checker.check_languages方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.check_languages方法的具体用法?Python Checker.check_languages怎么用?Python Checker.check_languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.checker.Checker
的用法示例。
在下文中一共展示了Checker.check_languages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validates_user
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_languages [as 别名]
def validates_user(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'nickname'):
check = False
checker.add_error(_('"%s" is required.') % _('Nickname'))
else:
check = checker.check_username(
_('Nickname'),
obj.input.nickname,
CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
min = USER_MIN_LENGTH,
max = USER_MAX_LENGTH,
) and check
if not is_param(obj.input, 'email'):
check = False
checker.add_error(_('"%s" is required.') % _('Mail Address'))
else:
check = checker.check_mailaddress(
_('Mail Address'),
obj.input.email,
CHECK_EMPTY | CHECK_LENGTH | CHECK_VALID,
min = EMAIL_MIN_LENGTH,
max = EMAIL_MAX_LENGTH,
) and check
_password_flag = True
if not is_param(obj.input, 'new_password'):
_password_flag = False
checker.add_error(_('"%s" is required.') % _('New Password'))
if not is_param(obj.input, 'retype'):
check = False
_password_flag = False
checker.add_error(_('"%s" is required.') % _('Retype'))
if _password_flag == True:
check = checker.check_password(
_('Password'),
obj.input.new_password,
obj.input.retype,
CHECK_VALID | CHECK_LENGTH | CHECK_EMPTY,
min = PASSWORD_MIN_LENGTH,
max = PASSWORD_MAX_LENGTH,
) and check
check = checker.check_languages(
_('Language'),
obj.input.languages,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH,
min = LANGUAGES_MIN_LENGTH,
max = LANGUAGES_MAX_LENGTH,
) and check
obj.view.alert = checker.errors
return check
示例2: validates_user
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_languages [as 别名]
def validates_user(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, "nickname"):
check = False
checker.add_error(_('"%s" is required.') % _("Nickname"))
else:
check = (
checker.check_username(
_("Nickname"),
obj.input.nickname,
CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
min=USER_MIN_LENGTH,
max=USER_MAX_LENGTH,
)
and check
)
if not is_param(obj.input, "email"):
check = False
checker.add_error(_('"%s" is required.') % _("Mail Address"))
else:
check = (
checker.check_mailaddress(
_("Mail Address"),
obj.input.email,
CHECK_EMPTY | CHECK_LENGTH | CHECK_VALID,
min=EMAIL_MIN_LENGTH,
max=EMAIL_MAX_LENGTH,
)
and check
)
_password_flag = True
if not is_param(obj.input, "password"):
check = False
_password_flag = False
checker.add_error(_('"%s" is required.') % _("Password"))
if not is_param(obj.input, "new_password"):
_password_flag = False
checker.add_error(_('"%s" is required.') % _("New Password"))
if not is_param(obj.input, "retype"):
check = False
_password_flag = False
checker.add_error(_('"%s" is required.') % _("Retype"))
if _password_flag == True:
if not is_empty(obj.input.password) or not is_empty(obj.input.new_password) or not is_empty(obj.input.retype):
check = (
checker.check_password(
_("Password"),
obj.input.password,
obj.input.password,
CHECK_EMPTY | CHECK_LENGTH,
min=PASSWORD_MIN_LENGTH,
max=PASSWORD_MAX_LENGTH,
)
and check
)
check = (
checker.check_password(
_("Password"),
obj.input.new_password,
obj.input.retype,
CHECK_VALID | CHECK_LENGTH,
min=PASSWORD_MIN_LENGTH,
max=PASSWORD_MAX_LENGTH,
)
and check
)
check = (
checker.check_languages(
_("Language"),
obj.input.languages,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH,
min=LANGUAGES_MIN_LENGTH,
max=LANGUAGES_MAX_LENGTH,
)
and check
)
obj.view.alert = checker.errors
return check