当前位置: 首页>>代码示例>>Python>>正文


Python User.get方法代码示例

本文整理汇总了Python中db.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.models.User的用法示例。


在下文中一共展示了User.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import get [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",'')
     try:
         user = User.get(user_email = email)
     except:
         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", "/"))
     else:
         self.write('用户已经存在,请重新注册或直接登录')
开发者ID:xiaocao,项目名称:anwen.in,代码行数:27,代码来源:user.py

示例2: get

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import get [as 别名]
 def get(self, name):
     try:
         user = User.get(user_domain = name)
     except:
         self.redirect("/404")
     user.user_say = markdown.markdown(user.user_say)
     likenum = Like.select().where(user_id=user.id).count()
     user.gravatar = get_avatar(user.user_email,100)
     self.render("userhome.html", user = user,likenum = likenum)
开发者ID:xiaocao,项目名称:anwen.in,代码行数:11,代码来源:user.py

示例3: get

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import get [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)
开发者ID:xiaocao,项目名称:anwen.in,代码行数:22,代码来源:index.py

示例4: get

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import get [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)
开发者ID:excelgco,项目名称:anwen.in,代码行数:26,代码来源:index.py

示例5: user_exist

# 需要导入模块: from db.models import User [as 别名]
# 或者: from db.models.User import get [as 别名]
def user_exist(login, password):
    """
    Check if User exist in db. Raises AuthError exception if something goes wrong
    :param login: string
    :param password: string
    :return: User object
    :raise AuthError:
    """
    try:
        user = User.get(User.login == login)
    except User.DoesNotExist:
        raise AuthError(u"Пользователь с логином {} не найден в базе данных".format(login))
    if create_hash(login, password) == user.password:
        return user
    else:
        raise AuthError(u"Логин не соответствует паролю")
开发者ID:bitnic028,项目名称:EGRProduction,代码行数:18,代码来源:helpers.py


注:本文中的db.models.User.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。