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


Python User.objects方法代码示例

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


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

示例1: get_login_techkids

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def get_login_techkids():
    username = request.args.get('username')
    password = request.args.get('password')
    for user in User.objects(user_name=username):
        if (user.password == password):
            return json.dumps({"login_status": 1, "login_message": "Login Success", "link":"http://iliat.org/download.txt"})
    return json.dumps({"login_status": 0, "login_message": "Login Failed"})
开发者ID:qhuydtvt,项目名称:iliat-erp-dump,代码行数:9,代码来源:app.py

示例2: gmat_login

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
def gmat_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({"login_status":1, "login_message":"Login Success"})
    return json.dumps({"login_status":0, "login_message":"Login Failed"})
开发者ID:qhuydtvt,项目名称:iliat-erp-dump,代码行数:9,代码来源:app.py

示例3: get

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

        users = User.objects(facebook_id=fb_id)

        if len(users) > 1:
            raise {'status': 'fail', 'message': 'Multiple facebook id detected.'}
        elif len(users) == 0:
            return {'status': 'fail', 'message': 'Invalid facebook id.'}

        user = users[0]

        list_friend = []
        for f in user.friends:
            list_friend.append(f.facebook_id)

        return {'status': 'success', 'friends': list_friend}
开发者ID:akaraspt,项目名称:hacklondon2016,代码行数:18,代码来源:api.py

示例4: post

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

        # Check training status
        response = requests.get(
            'https://api.projectoxford.ai/face/v1.0/persongroups/{}/training'.format(
                persongroups_id
            ),
            headers={
                'Ocp-Apim-Subscription-Key': sub_key
            }
        )
        response_json = response.json()
        if response_json.get('error'):
            return {'status': 'fail', 'message': response_json.get('error')}
        if response_json.get('status') != 'succeeded':
            return {'status': 'fail', 'message': 'The system is busy. Please try again.'}

        # ====================================================================================

        # Get a list of friends
        users = User.objects(facebook_id=fb_id)

        if len(users) > 1:
            raise {'status': 'fail', 'message': 'Multiple facebook id detected.'}
        elif len(users) == 0:
            return {'status': 'fail', 'message': 'Invalid facebook id.'}

        user = users[0]

        list_friend = []
        for f in user.friends:
            list_friend.append(f.facebook_id)

        # ====================================================================================

        # Get a list of friends of friends
        dict_fof = {}
        for f_fb_id in list_friend:

            # Get a list of friends
            users = User.objects(facebook_id=f_fb_id)

            if len(users) > 1:
                raise {'status': 'fail', 'message': 'Multiple facebook id detected.'}
            elif len(users) == 0:
                return {'status': 'fail', 'message': 'Invalid facebook id.'}

            user = users[0]

            f_list_friend = []
            for ff in user.friends:
                if ff.facebook_id != fb_id:
                    f_list_friend.append(ff.facebook_id)

            dict_fof[f_fb_id] = f_list_friend

        # ====================================================================================

        # Get upload file
        file = request.files.get('file')
        if file:
            # Get the secure filename
            filename = secure_filename(file.filename)

            # Check for allowed extension
            if allowed_file(file.filename):
                # Save file to disk
                upload_file_path = os.path.join(app.config['TMP_FOLDER'], filename)
                file.save(upload_file_path)

                # If there is upload file
                if os.path.isfile(upload_file_path):
                    # Send upload file to detect faces
                    with open(upload_file_path, 'rb') as data_file:
                        response = requests.post(
                            'https://api.projectoxford.ai/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=true&returnFaceAttributes=age,gender',
                            headers={
                                'Content-Type': 'application/octet-stream',
                                'Ocp-Apim-Subscription-Key': sub_key
                            },
                            data=data_file.read()
                        )

                        response_json = response.json()
                        if not isinstance(response_json, list):
                            if response_json.get('error'):
                                return {'status': 'fail', 'message': response_json.get('error')}

                    # Remove uploaded file from the upload directory, as it has already been stored in database
                    os.remove(upload_file_path)

                    # Get return face_id, which are used to refer to the detected faces
                    list_face_id = []
                    dict_face_id = {}
                    for r in response_json:
                        list_face_id.append(r.get('faceId'))
                        dict_face_id[r.get('faceId')] = r.get('faceRectangle')

                    if len(list_face_id) == 0:
                        return {'status': 'fail', 'message': 'No face detected.'}
#.........这里部分代码省略.........
开发者ID:akaraspt,项目名称:hacklondon2016,代码行数:103,代码来源:api.py

示例5: load_user

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import objects [as 别名]
 def load_user(user_id):
     return User.objects(id=user_id).first()
开发者ID:zendyani,项目名称:dzlibs,代码行数:4,代码来源:app.py


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