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


Python User.save方法代码示例

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


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

示例1: facebook_authorized

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
def facebook_authorized():
    resp = facebook.authorized_response()
    if resp is None:
        return 'Access denied: reason=%s error=%s' % (
            request.args['error_reason'],
            request.args['error_description']
        )
    if isinstance(resp, OAuthException):
        return 'Access denied: %s' % resp.message

    session['oauth_token'] = (resp['access_token'], '')
    me = facebook.get('/me')
    username = me.data['name']
    email= me.data['email']
    user = User.objects(email=email).first()
    if user:
        session['user_id'] = str(user.id)
    else:
        user = User()
        user.email = email
        user.username = username
        user.save()
        Inventory(owner=user.to_dbref(),
                      name='Basic',
                      is_basic=True).save()

    return redirect('/')
开发者ID:Rmanolis,项目名称:rpg-demo,代码行数:29,代码来源:app.py

示例2: post_app

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
def post_app():
    #print('form')
    signed_request = request.form.get('signed_request')
    data = facebook_tools.parse_signed_request(signed_request,
                                              FACEBOOK_APP_SECRET)
    print(signed_request)
    print(data)
    session['oauth_token'] = (data['oauth_token'],'')
    me = facebook.get('/me')
    username = me.data['name']
    email= me.data['email']
    user = User.objects(email=email).first()
    if user:
        session['user_id'] = str(user.id)
    else:
        user = User()
        user.email = email
        user.username = username
        user.save()
        Inventory(owner=user.to_dbref(),
                      name='Basic',
                      is_basic=True).save()


    return send_file('public/index.html')
开发者ID:Rmanolis,项目名称:rpg-demo,代码行数:27,代码来源:app.py

示例3: createUser

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
    def createUser(self, args):
        self._start(args)

        while True:
            username = raw_input('Enter email address: ')
            if User.users().get(username=username):
                print('Username already exists. Please pick another username.')
            else:
                break
            print('username: %s' % username)
        while True:
            is_admin = raw_input('Admininstrative user? (y/N): ')
            if (len(is_admin) == 0) or (is_admin.upper() == 'N'):
                admin = False
                break
            elif is_admin.upper() == 'Y':
                admin = True
                break
        while True:
            password_1 = getpass.getpass('Enter password: ')
            password_2 = getpass.getpass('Re-enter password: ')
            if password_1 != password_2:
                print('Passwords do not match.')
            else:
                break

        user = User(username, password_1, admin)
        user.save()
        # Db.instance().insert_user(username, password_1, admin)
        print('Successfully created user %s' % username)
开发者ID:silverfernsys,项目名称:sremote,代码行数:32,代码来源:app.py

示例4: test_does_not_find_by_invalid_credentials

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def test_does_not_find_by_invalid_credentials(self):
     user = User(email_address="[email protected]",
                 password="password")
     user.save()
     get_user = User.find_by_credentials(email_address="[email protected]",
                                         password="WrongPassword")
     self.assertIsNone(get_user)
开发者ID:ironunicorn,项目名称:rider_ai,代码行数:9,代码来源:test_user.py

示例5: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def create_user(self):
     user = User()
     user.username = 'test_username'
     user.password = 'test_password'
     user.name = 'test_name'
     user.email = '[email protected]'
     user.save()
     return user
开发者ID:aldarionsevero,项目名称:BusinemeWeb,代码行数:10,代码来源:test_post.py

示例6: users

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
def users(eid):
    if eid:
        if request.method == 'POST':
            user = User(eid = eid).from_form(request.form)
            user.save()
        else:
            user = User().get(eid = eid)
        return menu.render('form.html', form = user.as_form())
    else:
        return menu.render('list.html', items = User().all())
开发者ID:oromerob,项目名称:gallerybot,代码行数:12,代码来源:app.py

示例7: test_delete_user_wrong

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def test_delete_user_wrong(self):
     """the id does not match a user"""
     user_args = {"first_name": "quokka", "id": "QO",
                  "email": "[email protected]", "password": "1234"}
     user = User(**user_args)
     user.save()
     rv = self.app.delete('{}/users/{}/'.format(self.path, "noID"),
                          follow_redirects=True)
     self.assertEqual(rv.status_code, 404)
     storage.delete(user)
开发者ID:butcallmeJo,项目名称:airbnb_clone,代码行数:12,代码来源:test_users.py

示例8: testRawUserSave

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
    def testRawUserSave(self):
        user = User(firstName="John", lastName="Skauge", userName="John", password="MyPassword")
        # noinspection PyUnresolvedReferences
        self.assertFalse(user.id)
        user.save()
        self.assertTrue(user.id)

        user.delete()

        #this will throw a DoesNotExist error, hence the @unittest.expectedFailure
        user = User.objects.get(id=user.id)
开发者ID:Modulus,项目名称:FlaskDemo,代码行数:13,代码来源:user_resource_test.py

示例9: createUser

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
def createUser():
  user = User({
          "username": request.form.get('username'),
          "email": request.form.get('email'),
          "password": request.form.get('password'),
          "created": time.time()
        })
  
  user.save()

  response = { "success": True, "user": user.__dict__ }
  return dumps(response)
开发者ID:tkivari,项目名称:tgr,代码行数:14,代码来源:users.py

示例10: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
    def create_user(self, data):
        try: 
            province =self.provinces[data[1]]
        except: 
            province=0

        u=User()
        u.uid=data[0]
        u.province=data[1]
        u.gender=data[2]
        u.verified=data[3]
        u.save() # store to mongo
开发者ID:clemsos,项目名称:topogram-miner,代码行数:14,代码来源:users.py

示例11: test_update_user_bad_id

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def test_update_user_bad_id(self):
     """test update with no matching id"""
     user_args = {"first_name": "quokka", "id": "QO",
                  "email": "[email protected]", "password": "1234"}
     user = User(**user_args)
     user.save()
     rv = self.app.put('{}/users/{}/'.format(self.path, "noID"),
                       content_type="application/json",
                       data=json.dumps({"id": "Z"}),
                       follow_redirects=True)
     self.assertEqual(rv.status_code, 404)
     storage.delete(user)
开发者ID:butcallmeJo,项目名称:airbnb_clone,代码行数:14,代码来源:test_users.py

示例12: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def post(self):
     email = self.get_argument('email', '')
     form = UserForm(self.request.arguments)
     if not form.validate():
         self.render('auth/signup.html', error_message='', form=form)
     elif User.exists_email(email):
         error_message = '既に存在するメールアドレスです。'
         self.render('auth/signup.html', error_message=error_message, form=form)
     else:
         user = User(**form.data)
         user.save()
         self.redirect(self.reverse_url('login'))
开发者ID:ko-he-,项目名称:Brain_Hacker,代码行数:14,代码来源:auth_handler.py

示例13: test_update_user_bad_json

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def test_update_user_bad_json(self):
     """test update with ill formed json"""
     user_args = {"first_name": "quokka", "id": "QO2",
                  "email": "[email protected]", "password": "1234"}
     user = User(**user_args)
     user.save()
     rv = self.app.put('{}/users/{}/'.format(self.path, user.id),
                       content_type="application/json",
                       data={"id": "Z"},
                       follow_redirects=True)
     self.assertEqual(rv.status_code, 400)
     self.assertEqual(rv.get_data(), b"Not a JSON")
     storage.delete(user)
开发者ID:butcallmeJo,项目名称:airbnb_clone,代码行数:15,代码来源:test_users.py

示例14: test_delete_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import save [as 别名]
 def test_delete_user(self):
     """test delete a user"""
     user_args = {"first_name": "quokka", "id": "QO",
                  "email": "[email protected]", "password": "1234"}
     user = User(**user_args)
     user.save()
     rv = self.app.delete('{}/users/{}/'.format(
         self.path, user_args["id"]),
                                follow_redirects=True)
     self.assertEqual(rv.status_code, 200)
     self.assertEqual(rv.headers.get("Content-Type"), "application/json")
     json_format = getJson(rv)
     self.assertEqual(json_format, {})
     self.assertIsNone(storage.get("User", user_args["id"]))
开发者ID:butcallmeJo,项目名称:airbnb_clone,代码行数:16,代码来源:test_users.py

示例15: run

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

        User.drop_collection()
        Message.drop_collection()

        user1 = User()
        user2 = User()
        user3 = User()
        user4 = User()

        user1.firstName = "John"
        user1.lastName = "Doe"
        user1.birthDate = datetime.now()
        user1.userName = "Creator"
        user1.passHash = user1.userName

        user2.firstName = "Jane"
        user2.lastName = "Doe"
        user2.birthDate = datetime.now()
        user2.userName = "Nemesis"
        user2.passHash = user2.userName

        user3.firstName = "Michelle"
        user3.lastName = "Nielsen"
        user3.birthDate = datetime.now()
        user3.userName = "GoldDigger86"
        user3.passHash = user3.userName

        user4.firstName = "Leif"
        user4.lastName = "Paulsen"
        user4.birthDate = datetime.now()
        user4.userName = "The_Artist"
        user4.passHash = user4.userName

        user1.save()
        user2.save()
        user3.save()
        user4.save()

        message1 = Message()
        message1.subject = "First message"
        message1.text = "This is the first message ever in the system. Hello Jane this is John, how are you?"
        message1.sender = user1
        message1.receiver = user2
        message1.save()

        message2 = Message()
        message2.subject = "Second message"
        message2.text = "This is the second message ever in the system. Hello Jane this is Åge, how are you?"
        message2.sender = user4
        message2.receiver = user2
        message2.save()

        message3 = Message()
        message3.subject = "Second message"
        message3.text = "This is the Third message ever in the system. Hello Jane this is Åge, how are you?"
        message3.sender = user4
        message3.receiver = user1
        message3.save()
开发者ID:Modulus,项目名称:Flask-RestfulDemo,代码行数:61,代码来源:populator.py


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