本文整理汇总了Python中user.User.find_one方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_one方法的具体用法?Python User.find_one怎么用?Python User.find_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.find_one方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import find_one [as 别名]
def post(self):
from afutils.user_utils import email_verification
handler_para = VerificationMailPara(self)
handler_json = VerificationMailJson(self)
pre_time = self.get_cookie("repeat", None)
cur_time = time.time()
usr = self.current_user
if pre_time and cur_time - float(pre_time) < 30:
handler_json.by_status(5)
handler_json.write()
return # within 30s
if usr is None:
usr = User.find_one({"email": handler_para["email"].lower()})
if usr is None:
handler_json.by_status(2)
handler_json.write()
return # user not exist
if usr.account_status != "unverified":
handler_json.by_status(1)
handler_json.write()
return # already verified user
else:
status = email_verification(usr)
self.set_cookie("repeat", str(time.time()))
if status:
handler_json.by_status(0)
else: # send failed
handler_json.by_status(3)
handler_json.write()
return # send status
示例2: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import find_one [as 别名]
def get(self):
page = CheckPage(self)
email = self.get_esc_arg("email")
token = self.get_esc_arg("token")
check_type = self.get_esc_arg("type", "mail")
status_code = 0
if check_type not in ("mail", "reset"):
check_type = "mail"
if not email or not token:
status_code = 4 # invalid check
else:
if check_type not in ("mail", "reset"):
check_type = "mail"
email = email.lower()
usr = User.find_one({"email": email})
if usr.data is None:
status_code = 1
elif usr.token == token:
if check_type == "mail":
usr.token = ""
if usr.account_status == u"unverified":
usr.account_status = u"normal"
else:
pwd = usr.token[:40]
usr.set_propertys(token="", password=pwd)
else:
status_code = 2 if check_type == "mail" else 3
page.set_args(status_code, check_type=check_type)
page.render()
return
示例3: get_init
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import find_one [as 别名]
def get_init(self, uid=None):
from user import User
usr = self.current_user
self.usr= usr
if uid is None:
if usr is None:
self.redirect('/login')
return
self.author = usr
else:
self.author = User.by_id(uid)
if self.author is None:
self.author = User.find_one({'domain':uid})
if self.author is None:
self.send_error(404)
return
示例4:
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import find_one [as 别名]
#!/usr/bin/env python
from article.blog import Blog
from user import User
bids = ['5020dbdb37251703ac000005', '502266ba3725170e83000002', '502267a83725170e82000002', '502267a83725170e85000002', '50226ddd3725170ef3000003', '50227fef3725170f90000008']
blogobjs = Blog.by_ids(bids)
user_af = User.find_one({'email':'[email protected]'})
for each in blogobjs:
each.set_propertys(env=user_af, author=user_af)
user_af.add_tags(each.tag)
user_af.post_blog(each)
示例5: len
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import find_one [as 别名]
#!/usr/bin/env python
'''
usage:
add_invitations count email
count is a number, email could be 'all'
'''
from user import User
import sys
if __name__ == '__main__':
if len(sys.argv) != 3:
print('Invalid arguments: usage: command count email')
count = int(sys.argv[1])
email = sys.argv[2]
if email == 'all':
for each in User.find():
each.invitations += count
else:
usr = User.find_one({'email':email})
usr.invitations += count