本文整理汇总了Python中tinyms.core.common.Utils.email_account_name方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.email_account_name方法的具体用法?Python Utils.email_account_name怎么用?Python Utils.email_account_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyms.core.common.Utils
的用法示例。
在下文中一共展示了Utils.email_account_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import email_account_name [as 别名]
def create(self):
account_name = self.param("account_name")
if not account_name:
return "AccountNameRequired"
email = self.param("email")
if not email:
return "EmailRequired"
pwd = self.param("pwd")
if not pwd:
return "PwdRequired"
agree = self.param("agree")
print(agree)
if not agree:
return "AgreeRequired"
re_pwd = self.param("re_pwd")
if pwd != re_pwd:
return "PwdNotSame"
sf = SessionFactory.new()
num = sf.query(func.count(Account.id)).filter(Account.login_name == account_name).scalar()
if num > 0:
return "AccountExists"
num = sf.query(func.count(Archives.id)).filter(Archives.email == email).scalar()
if num > 0:
return "EmailExists"
#create a person
length = len(str(sf.query(func.count(Archives.id)).scalar()))
max_length = AppSettingHelper.get("s_usr_code_fmt_length", "5")
prefix = AppSettingHelper.get("s_usr_code_prefix", "P")
if length > Utils.parse_int(max_length):
max_length = "%s" % (length + 1)
fmt = prefix + "%0" + max_length + "d"
p = Archives()
p.email = email
p.name = Utils.email_account_name(email)
p.join_date = Utils.current_datetime()
sf.add(p)
sf.flush()
p.code = fmt % p.id
u = Account()
u.login_name = account_name
u.login_pwd = Utils.md5(pwd)
u.create_time = Utils.current_datetime()
u.last_logon_time = Utils.current_datetime()
u.enabled = 1
u.archives_id = p.id
sf.add(u)
sf.flush()
default_role_id = Utils.parse_int(AppSettingHelper.get("s_usr_register_default_role_name", 0))
if default_role_id > 0:
default_role = sf.query(Role).get(default_role_id)
if default_role:
u.roles.append(default_role)
sf.commit()
self.request.set_secure_cookie(IRequest.__key_account_id__, "%i" % u.id)
self.request.set_secure_cookie(IRequest.__key_account_name__, email)
return "Success"