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


Python User.save方法代码示例

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


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

示例1: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
    def post(self):
        args = fbUserParser.parse_args()
        fb_id = args['fbid']
        fb_token = args['fbtoken']   
        if fb_id is None or fb_token is None:
           abort(400)

        fbuser_info = requests.get('https://graph.facebook.com/me?access_token=%s' %fb_token).json()
        if not fbuser_info.get('id') or fb_id != fbuser_info['id']:
            raise InvalidUsage('User info does not match',406)

        fb_email = args['fbemail']
        user = User.objects(email=fb_email).first()
        
        if user is None:
            user = User(email=fb_email, fb_id=fbuser_info['id'])
            user.save()
            
        profile = Profile.objects(user=user).first()
        if profile is None:
            profile = Profile(user=user)
            profile.save()

        rongToken = rongcloudToken(profile.id)
        token = user.generate_auth_token()
        redis_store.set(str(user.id), token)
        return {'token': token, 'rongToken' : rongToken}
开发者ID:bintao,项目名称:cteemo,代码行数:29,代码来源:userAPI.py

示例2: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
    def post(self):
        """
        Sign up with Facebook account and return a token
        """
        args = fbUserParser.parse_args()
        fb_id = args['fbid']
        fb_token = args['fbtoken']
        fb_email = args['fbemail']
        if fb_id is None or fb_token is None or fb_email is None:
            abort(400)

        # verify the user's facebook account using the facebook token
        fbuser_info = requests.get(
            'https://graph.facebook.com/me?access_token=%s' % fb_token).json()
        if not fbuser_info.get('id') or fb_id != fbuser_info['id']:
            abort(406)

        user = User(email=fb_email, fb_id=fb_id)
        try:
            user.save()
        except:
            return {'status': 'error', 'message': 'FBname has already existed'}

        token = user.generate_auth_token(expiration=360000)
        redis_store.set(str(user.id), token)
        return ({'status': 'success', 'token': token}, 201)
开发者ID:Xuefeng-Zhu,项目名称:flask-user-api,代码行数:28,代码来源:userAPI.py

示例3: create

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
def create(request):
    '''
    if(request.method != 'POST'): 
        return HttpResponse("Invalid create request", status=503)
    json_data = simplejson.loads(request.raw_post_data)
    '''
    json_data = request.REQUEST  # Getting all the request parameters as json string
    print json_data 
    ' Check to see if all params have empty values'    
    jsondataempty=True
    for val in json_data.values():
        if val:
            jsondataempty=False
        
    if jsondataempty:
        ret = {
               'success':False,
               'id':'',
               'error':'All input fields are empty'
        }
    else:
        u = User()
        for name in json_data:
            # TODO: Add validation of attribute names and values 
            u.__dict__[name] = json_data[name]
        u.save()
        ret = {
           'success':True,
           'id':str(u._id)
        }
    return HttpResponse(simplejson.dumps(ret),"application/json")
开发者ID:vebsiam2,项目名称:vebsiam2-server,代码行数:33,代码来源:user.py

示例4: register

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
def register(user_info, user_type):
	nuser = User(firstName = user_info['firstName'], lastName = user_info['lastName'], email = user_info['email'], password = user_info['password'], userType = user_type)
	try:
		nuser.save()
		return True
	except NotUniqueError:
		return False
开发者ID:velicue,项目名称:contestify,代码行数:9,代码来源:userauth.py

示例5: createfromjson

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
def createfromjson(json_data):
    u = User()
    for name in json_data:
        # TODO: Add validation of attribute names and values 
        u.__dict__[name] = json_data[name]
    u.save()
    ret = {
       'success':True,
       'id':str(u._id)
    }
    return HttpResponse(simplejson.dumps(ret),"application/json")
开发者ID:vebsiam2,项目名称:vebsiam2-server,代码行数:13,代码来源:user.py

示例6: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
    def post(self):
        args = userParser.parse_args()
        email = args['email']
        password = args['password']
        if email is None or password is None:
            abort(400)

        user = User(email=email, is_activated=True)
        user.hash_password(password)
        try:
            user.save()
        except ValidationError, e:
            return {'status': 'error', 'message': e.message}
开发者ID:bintao,项目名称:cteemo,代码行数:15,代码来源:userAPI.py

示例7: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
 def post(self):
     # email = request.form.get('email')
     username = request.form.get('username')
     password = request.form.get('password')
     if username is None or password is None:
         abort(400)    # missing arguments
     user = User(username=username)
     user.hash_password(password)
     try:
         user.save()
     except:
         return {'status': 'error', 'message': 'username has already existed'}
     return ({'username': user.username}, 201)
开发者ID:Xuefeng-Zhu,项目名称:flask-sample,代码行数:15,代码来源:userAPI.py

示例8: register

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import save [as 别名]
	def register(self, cmd_params):
		username = cmd_params['username']['value']
		password = cmd_params['password']['value']
		user = User(username, password)
		uid = user.get_uid()

		error = False
		dbconn = DBConnection(conf.DB_USER)
		cursor = dbconn.get_cursor()
		if DBConnection.is_user_existed(cursor, user):
			print 'User %s has already been register, you can login directly.' % (username)

		user.save()
		print 'User %s registers successfully.'
		return [('error', error, TYPE.BOOLEAN)]
开发者ID:JumsphenmXu,项目名称:code,代码行数:17,代码来源:server.py


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