本文整理汇总了Python中tinyms.core.common.Utils.md5方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.md5方法的具体用法?Python Utils.md5怎么用?Python Utils.md5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyms.core.common.Utils
的用法示例。
在下文中一共展示了Utils.md5方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pack_client
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def pack_client(self):
user_id = self.get_current_user()
root_path = self.get_webroot_path()
download_path = root_path + "/download/validwork/"
Utils.mkdirs(download_path)
client_zip_name = download_path + Utils.md5("%i_client" % user_id) + ".zip"
key_file_name = download_path + Utils.md5("%i_keyfile" % user_id)
ip_file_name = download_path + "ip.txt"
exe_file_name = download_path + "FingerTemplateHelper.exe"
libcurl = download_path + "libcurl.dll"
zlib1 = download_path + "zlib1.dll"
if os.path.exists(key_file_name):
os.remove(key_file_name)
key = self.kengen()
Utils.text_write(key_file_name, [key], "")
if not os.path.exists(ip_file_name):
Utils.text_write(ip_file_name, [self.request.host], "")
if os.path.exists(client_zip_name):
os.remove(client_zip_name)
f = ZipFile(client_zip_name, "w")
self.compress(f, ip_file_name, "ip.txt")
self.compress(f, key_file_name, "temp.key")
self.compress(f, exe_file_name, "指纹采集助手.exe")
self.compress(f, libcurl, "libcurl.dll")
self.compress(f, zlib1, "zlib1.dll")
f.close()
return client_zip_name
示例2: post
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def post(self, *args, **kwargs):
"""
do login action
:param args:
:param kwargs:
"""
login_id = self.get_argument("login_id")
login_pwd = self.get_argument("login_pwd")
if not login_id or not login_pwd:
self.redirect(self.get_login_url())
cnn = SessionFactory.new()
if Utils.is_email(Utils.trim(login_id)):
rows = cnn.query(Account.id, Archives.name).outerjoin(Archives, Account.archives_id == Archives.id) \
.filter(Archives.email == login_id).filter(Account.login_pwd == Utils.md5(login_pwd)) \
.filter(Account.enabled == 1).limit(1).all()
if len(rows) > 0:
id_ = rows[0][0]
name = rows[0][1]
self.set_secure_cookie(IRequest.__key_account_id__, "%i" % id_)
self.set_secure_cookie(IRequest.__key_account_name__, name)
Login.update_last_login_datetime(id_)
else:
rows = cnn.query(Account.id, Archives.name).outerjoin(Archives, Account.archives_id == Archives.id) \
.filter(Account.login_name == login_id).filter(Account.login_pwd == Utils.md5(login_pwd)) \
.filter(Account.enabled == 1).limit(1).all()
if len(rows) > 0:
id_ = rows[0][0]
name = rows[0][1]
self.set_secure_cookie(IRequest.__key_account_id__, "%i" % id_)
self.set_secure_cookie(IRequest.__key_account_name__, name)
Login.update_last_login_datetime(id_)
self.redirect("/workbench/dashboard")
示例3: render
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def render(self, id_, target, type_="table"):
"""
:param id_: dom id
:param target: DataTable's entity property Or DataView's view property value
:param type_: 'table' or 'view'
:return:
"""
key = Utils.md5(target)
point = None
if type_ == "table":
point = DataTableModule.__security_points__.get(key)
elif type_ == "view":
point = DataViewModule.__security_points__.get(key)
html = list()
if AccountHelper.auth(self.current_user, {point.add, point.update, point.delete}):
html.append('<div class="form-group"><div class="col-lg-9 col-lg-offset-3">')
html.append(
'<input type="button" class="btn btn-primary btn-sm" id="%s_form_save" onclick="%s_.form.save(this,%s);" value="保存"></button>'
% (id_, id_, "''")
)
html.append(
' <input type="button" class="btn btn-white btn-sm" id="%s_form_save_continue" onclick="%s_.form.save(this,%s);" value="保存并继续"></button>'
% (id_, id_, "'clear'")
)
html.append(
' <input type="button" class="btn btn-white btn-sm" id="%s_form_reset" onclick="%s_.form.reset(this);" value="重填"></button>'
% (id_, id_)
)
html.append("</div></div>")
html.append("</form>")
return "".join(html)
示例4: save
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def save(self, kv, http_req):
_usr_old_pwd = kv.get("_usr_old_pwd")
_usr_new_pwd = kv.get("_usr_new_pwd")
_usr_new_repwd = kv.get("_usr_new_repwd")
if _usr_old_pwd and _usr_new_pwd:
if _usr_new_pwd == _usr_new_repwd:
usr_id = http_req.current_user
sf = SessionFactory.new()
num = sf.query(func.count(Account.id)).filter(Account.id == usr_id) \
.filter(Account.login_pwd == Utils.md5(_usr_old_pwd)).scalar()
if num > 0:
a = sf.query(Account).get(usr_id)
a.login_pwd = Utils.md5(_usr_new_pwd)
sf.commit()
return ""
else:
return "PasswordError"
else:
return "PasswordNotSame"
示例5: update
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def update(id_, login_id, pwd, archives_id=None, enabled=False):
cnn = SessionFactory.new()
a = cnn.query(Account).get(id_)
a.login_name = login_id
if pwd:
a.login_pwd = Utils.md5(pwd)
a.enabled = enabled
a.archives_id = archives_id
cnn.commit()
return "Updated"
示例6: render
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def render(self, **p):
self.dom_id = p.get("id") #dom id
self.provider = p.get("provider") #datasource json url
self.key = Utils.md5(self.provider)
self.placeholder = p.get("placeholder") #tip
self.at = p.get("at")
if not self.at:
self.at = ""
self.item_tpl = "<li data-value='${value}' data-key='${key}'>${value}</li>"
item_tpl = p.get("item_tpl")
if item_tpl:
self.item_tpl = item_tpl
return self.render_string("widgets/autocomplete.html", id=self.dom_id, key=self.key, item_tpl=self.item_tpl,
at=self.at, placeholder=self.placeholder)
示例7: get
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def get(self, *args, **kwargs):
context = dict()
categories = self.role_categories()
all_ = list()
for c in categories:
sub = list()
groups = self.role_groups(c)
for g in groups:
sub.append((g, self.points(c, g)))
all_.append((c, sub, Utils.md5(c)))
context["categories"] = all_
context["roles_for_account"] = self.role_for_account()
return self.render("workbench/role_org.html", data=context)
示例8: create
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def create(login_id, pwd, archives_id=None, enabled=0):
cnn = SessionFactory.new()
obj = Account()
obj.login_name = login_id
obj.login_pwd = Utils.md5(pwd)
obj.create_time = Utils.current_datetime()
obj.enabled = enabled
obj.archives_id = archives_id
cnn.add(obj)
cnn.flush()
default_role_id = Utils.parse_int(AppSettingHelper.get("s_usr_register_default_role_name", "0"))
if default_role_id > 0:
default_role = cnn.query(Role).get(default_role_id)
if default_role:
obj.roles.append(default_role)
cnn.commit()
return obj.id
示例9: create_root_account
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def create_root_account(role_id):
cnn = SessionFactory.new()
num = cnn.query(func.count(Archives.id)).scalar()
role_ = cnn.query(Role).get(role_id)
if num == 0:
usr = Archives()
usr.name = u"超级管理员"
usr.email = "[email protected]"
usr.code = "P00001"
cnn.add(usr)
cnn.commit()
a = Account()
a.login_name = "root"
a.login_pwd = Utils.md5("root")
a.create_time = datetime.now()
a.enabled = 1
a.archives_id = usr.id
cnn.add(a)
a.roles.append(role_)
cnn.commit()
示例10: create
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [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"
示例11: ref_ac
# 需要导入模块: from tinyms.core.common import Utils [as 别名]
# 或者: from tinyms.core.common.Utils import md5 [as 别名]
def ref_ac(cls):
ObjectPool.autocomplete_keys[Utils.md5(id_)] = cls
return cls