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


Python User.objects方法代码示例

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


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

示例1: get

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
    def get(self):
        async_client = AsyncHTTPClient()
        auth_code = self.get_argument("code", None)
        if auth_code:
            # 第一步 获取access_token
            auth_token_url = self.__build_auth_token_url(auth_code)
            token_response = yield async_client.fetch(auth_token_url)
            access_token, refresh_token = self.__parse_token(token_response)

            # 第二不 得到用户身份信息
            auth_me_url = self.__build_auth_me_url(access_token)
            open_response = yield async_client.fetch(auth_me_url)
            openid = self.__parse_me(open_response)

            # 第三布 获取用户基本信息
            auth_user_url = self.__build_auth_user_url(access_token, openid)
            user_info = yield async_client.fetch(auth_user_url)
            user = self.__parse_user(user_info, access_token, refresh_token, openid)
            # 确认用户是否已经登录过
            try:
                user = User.objects(type='qq', uid=openid)[0]
            except Exception as ex:
                app_log.exception(ex)
            finally:
                user.save()
                self.set_secure_cookie('userid', str(user.id))
                self.set_secure_cookie('type', 'qq')
                self.redirect("/")
        else:
            # 登录失败,跳转到登录页面
            self.redirect("/sigin")
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:33,代码来源:__init__.py

示例2: login

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
def login():
    user_name = request.form['username'];
    password = request.form['password'];
    for user in User.objects(user_name=user_name):
        if(user.password == password):
            return json.dumps({"result_code":1, "result_message":"Login succeded"})
    return json.dumps({"result_code":0, "result_message":"Login failed"})
开发者ID:huynq-tk-ios3,项目名称:iliat-erp-dump,代码行数:9,代码来源:app.py

示例3: get

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
    def get(self, id):
        user = User.objects(id=id)[0]
        books = Book.objects(likes__in=[user])
        bgs = self.grouped(books)

        kwargs = {
            "page_heading": unicode(user.name),
            "groups": self.get_groups(),
            "user": user,
            "books": books,
            "bgs": bgs
        }
        self.render('user.html', **kwargs)
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:15,代码来源:user_handler.py

示例4: get

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
    def get(self):

        if self.get_argument("openid.mode", None):

            result = yield self.get_authenticated_user()
            try:
                user = User.objects(type='google', email=result['email'])[0]
            except Exception as ex:
                app_log.error(ex)
                user = User(uid=str(uuid4()),
                            type='google',
                            email=result['email'],
                            name=result['name'],
                            avatar=getAvatar('email')
                )
                user.save()

            self.set_secure_cookie('userid', str(user.id))
            self.set_secure_cookie('type', 'google')
            self.redirect("/")
        else:
            yield self.authenticate_redirect()
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:24,代码来源:auth.py

示例5: post

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
 def post(self):
     email = self.get_argument('email').decode()
     password = self.get_argument('password').decode()
     try:
         user = User.objects(email=email, password=password).first()
         if not user:
             self.redirect('/sigin')
     except Exception as ex:
         app_log.error(ex)
         self.redirect('/sigin')
     else:
         self.set_secure_cookie('userid', str(user.id))
         self.set_secure_cookie('admin', "True")
         try:
             next_url = self.get_argument('next')
             if next_url:
                 self.redirect(next_url)
                 return
             self.redirect('/')
         except Exception as ex:
             app_log.exception(ex)
             self.redirect('/')
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:24,代码来源:auth.py

示例6: save_douban_user

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
 def save_douban_user(user):
     try:
         user = User.objects(type='douban', uid=user['uid'])[0]
     except Exception, e:
         app_log.error(e)
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:7,代码来源:__init__.py

示例7: get

# 需要导入模块: from models.users import User [as 别名]
# 或者: from models.users.User import objects [as 别名]
 def get(self):
     self.set_header("Content-Type", "application/json; charset=UTF-8")
     users = User.objects() \
         .exclude("password").exclude("access_token").exclude("uid").exclude('password')
     self.write(users.to_json())
开发者ID:yunlzheng,项目名称:PDFLabs,代码行数:7,代码来源:Gallery.py


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