本文整理汇总了Python中db.User.find方法的典型用法代码示例。如果您正苦于以下问题:Python User.find方法的具体用法?Python User.find怎么用?Python User.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.User
的用法示例。
在下文中一共展示了User.find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import find [as 别名]
def get(self, name):
user = User.find_one({"user_domain": name})
user.user_say = markdown2.markdown(user.user_say)
user.user_jointime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(user.user_jointime))
likenum = User.find({"user_id": user._id}).count()
user.gravatar = get_avatar(user.user_email, 100)
self.render("userhome.html", user=user, likenum=likenum)
示例2: post
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import find [as 别名]
def post(self):
name = self.get_argument("name", '')
password = self.get_argument("password", '')
password = hashlib.md5(password).hexdigest()
email = self.get_argument("email", '')
domain = self.get_argument("domain", '')
if domain == '':
domain = name
if User.find({'user_email': email}).count() > 0:
self.write('用户已经存在,请直接登录')
self.redirect("/login")
else:
res = User
res['id'] = res.find().count() + 1
res['user_name'] = name
res['user_pass'] = password
res['user_email'] = email
res['user_domain'] = domain
res.new(res)
user = {'user_id': res.id,
'user_name': res.user_name,
'user_email': res.user_email,
'user_domain': res.user_domain}
self.set_secure_cookie("user", tornado.escape.json_encode(user))
self.redirect(self.get_argument("next", "/"))
示例3: get
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import find [as 别名]
def get(self, node):
page = self.get_argument("page", 1)
share_res = Share.find({'sharetype': node}).sort(
'_id', DESCENDING).limit(10).skip((int(page) - 1) * 10)
pagesum = (share_res.count() + 9) / 10
shares = []
for share in share_res:
user = User.by_sid(share.user_id)
share.name = user.user_name
share.published = time.strftime(
'%Y-%m-%d %H:%M:%S', time.localtime(share.published))
share.domain = user.user_domain
share.markdown = filter_tags(
markdown2.markdown(share.markdown))[:100]
share.gravatar = get_avatar(user.user_email, 16)
shares.append(share)
members = User.find().sort('_id', DESCENDING).limit(20)
members_dict = []
for member in members:
member.gravatar = get_avatar(member.user_email, 25)
members_dict.append(member)
node_about = options.node_about[node]
self.render(
"node.html", shares=shares, members=members_dict,
pagesum=pagesum, page=page, node=node, node_about=node_about)
示例4: get
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import find [as 别名]
def get(self, name):
user = User.find_one({'user_domain': name})
user.user_jointime = time.strftime(
'%Y-%m-%d %H:%M:%S', time.localtime(user.user_jointime))
likes = User.find({'user_id': user._id})
likenum = likes.count()
for like in likes:
share = Share.by_id(like.share_id)
like.title = share.title
like.id = share.id
like.type = share.sharetype
user.gravatar = get_avatar(user.user_email, 100)
self.render("userlike.html", user=user, likenum=likenum, likes=likes)