本文整理汇总了Python中db.models.User.select方法的典型用法代码示例。如果您正苦于以下问题:Python User.select方法的具体用法?Python User.select怎么用?Python User.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.models.User
的用法示例。
在下文中一共展示了User.select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import select [as 别名]
def post(self):
if not self.request.headers.get("Cookie"):
self.render("require_enable_cookie.html")
return
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.select().where(user_email=email).count():
self.write('用户已经存在,请直接登录')
self.redirect("/login")
else:
u = User.create(user_name=name,
user_pass=password,
user_email=email,
user_domain=domain, )
user = {'user_id': u.id,
'user_name': u.user_name,
'user_email': u.user_email,
'user_domain': u.user_domain}
self.set_secure_cookie("user", tornado.escape.json_encode(user))
self.redirect(self.get_argument("next", "/"))
示例2: get
# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import select [as 别名]
def get(self, node):
page = self.get_argument("page", "1")
realpage = int(page)
shares = Share.select().where(
sharetype=node).order_by('id').paginate(realpage, 10)
sharesum = shares.count()
pagesum = (sharesum + 9) / 10
for share in shares:
user = User.get(id=share.user_id)
share.name = user.user_name
share.domain = user.user_domain
share.markdown = filter_tags(share.markdown)[:100]
share.gravatar = get_avatar(user.user_email, 16)
members = User.select().order_by('id').paginate(1, 20)
for member in members:
user = User.get(id=member.id)
member.gravatar = get_avatar(user.user_email, 35)
self.render(
"node.html", shares=shares, members=members,
pagesum=pagesum, page=page, node=node)
示例3: get
# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import select [as 别名]
def get(self):
page = self.get_argument("page", "1")
realpage = int(page)
shares = Share.select().order_by(('id', 'desc')).paginate(realpage, 10)
sharesum = shares.count()
pagesum = (sharesum + 9) / 10
for share in shares:
user = User.get(id=share.user_id)
share.name = user.user_name
share.domain = user.user_domain
share.markdown = filter_tags(
markdown.markdown(share.markdown))[:100]
share.gravatar = get_avatar(user.user_email, 16)
members = User.select().order_by(('id', 'desc')).paginate(1, 20)
for member in members:
user = User.get(id=member.id)
member.gravatar = get_avatar(user.user_email, 25)
Share.select().order_by(
('status', 'desc'), ('id', 'desc')).limit(5)
node = 'home'
node_about = options.node_about[node]
self.render(
"node.html", shares=shares, members=members,
pagesum=pagesum, page=page, node=node, node_about=node_about)
示例4: get
# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import select [as 别名]
def get(self):
members = User.select()
self.render("member.html", members = members)