当前位置: 首页>>代码示例>>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: index

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
def index():
    user = FacebookClient().process(bottle.request.GET['code'])
    
    if user:
        users = EntityManager(_DBCON).getAll(User, filterCriteria={'facebookUserId':user['id']})
        if users:
            _id = users[0]._id
        else:
            _id = None

        
        u = User(_DBCON, _id=_id)
        u.username = user['name']
        u.password = user['id']
        u.valid = False
        u.facebookUserId = user['id']
        u.save()
        
        s = Session(_DBCON)
        s.userid = u._id
        s.ip = bottle.request.get('REMOTE_ADDR')
        s.useragent = bottle.request.get('HTTP_USER_AGENT')
        s.save()
        
        s.set_cookie()
    
        bottle.redirect('/')
        
    else:
        bottle.redirect('/login')   
开发者ID:iamcm,项目名称:consensus,代码行数:32,代码来源:app.py

示例2: create_user

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
	def create_user(self):
		u = User(_DBCON)
		u.email = self.EMAIL
		u.password = self.PASSWORD
		u.save()

		return u
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:9,代码来源:user_test.py

示例3: setUp

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
    def setUp(self):
        self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)

        self.u1 = User.save(username1, email1, password1)
        self.u2 = User.save(username2, email2, password2)
开发者ID:Ramesh7128,项目名称:udacityplus,代码行数:10,代码来源:message_test.py

示例4: create_user

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
	def create_user(self, email='[email protected]', password='passpass', valid=True):
		u = User(self.conn)
		u.email = email
		u.password = password
		u.valid = valid
		u.save()

		return u
开发者ID:iamcm,项目名称:jug,代码行数:10,代码来源:BaseTest.py

示例5: test_password_is_still_the_same_after_user_instance_being_saved

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

		u = User(_DBCON, email=self.EMAIL, password=self.PASSWORD)
		u.save()

		#now try and get that user again with the same email and password
		u = User(_DBCON, email=self.EMAIL, password=self.PASSWORD)

		self.assertTrue(u._id is not None)
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:12,代码来源:user_test.py

示例6: test_change_password_bad

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

		u = User(_DBCON, email=self.EMAIL, password=self.PASSWORD)
		u.password = 'new'
		u.save()

		#now try and get that user again with the new email and password
		u = User(_DBCON, email=self.EMAIL, password='new')

		self.assertTrue(u._id is None)
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:13,代码来源:user_test.py

示例7: create_activated_user

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
	def create_activated_user(self):
		"""
		shortcut to save having to activate the user each time we 
		create one
		"""
		u = User(_DBCON)
		u.email = self.EMAIL
		u.password = self.PASSWORD
		u.valid = True
		u.save()

		return u
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:14,代码来源:user_test.py

示例8: setUp

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        # make sure you know what this does
        self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
        self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)

        self.u1 = User.save(username1, email1, password1)
        self.u2 = User.save(username2, email2, password2)

        self.createNewSource()
        self.createNewCourses()
        self.courses = self.createNewAttempts()
开发者ID:Ramesh7128,项目名称:udacityplus,代码行数:15,代码来源:user_test.py

示例9: testValidEmail

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
    def testValidEmail(self):
        e, err = User.valid_email(email1)
        self.assertEqual(e, True, "With no existing user")
        u = User.save(username1, email1, password1)
#        u.put()
        e, err = User.valid_email(email1)
        self.assertEqual(e, False, "After create user with the email being tested")
开发者ID:Ramesh7128,项目名称:udacityplus,代码行数:9,代码来源:user_test.py

示例10: index

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

    u = User(_DBCON, _id=bottle.request.session.userId)
    
    if u:
        key = generate_api_key()

        while EntityManager(_DBCON).get_all(User, filter_criteria={'apikey':key}, count=True) > 0:
            key = generate_api_key()

        u.apikey = key
        u.save()

    else:
        key = ''

    return key
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:19,代码来源:app.py

示例11: get

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
    def get(self, username):
        """display profile of user with username, if None, display logged in user
        """
        mode = self.request.get('mode')
        upload_url = ""

        if mode == 'add_project':
            template = 'profile/add_project.html'
            upload_url = blobstore.create_upload_url('/' + username, max_bytes_per_blob=self.MAX_IMG_SIZE)
        elif mode == 'edit_project':
            template = 'profile/edit_project.html'
            upload_url = blobstore.create_upload_url('/' + username, max_bytes_per_blob=self.MAX_IMG_SIZE)
        elif mode == 'edit':
            template = 'profile/edit.html'
        else:
            template = 'profile/profile.html'

           

        user = User.get_user(username)

        if not user:
            user = User.save(username, '{}@someplace.com'.format(username), 'some long password')


        gravatar = user.avatar_url
        friends = []

        

        if user:
            all, ic, cc = self.organize_courses_for(user)

            if user.dob:
                dob = user.dob.strftime('%m/%d/%Y')
            else:
                dob = None

            projects = Project.get_projects_by_ids(user.projects)

            context = {'user': user,
                       'dob': dob,
                       'username': username,
                       'gravatar': gravatar,
                       'friends': friends,
                       'friend_btn': False,
                       'courses_all': Course.courses_to_dict(),
                       'courses_completed': cc,
                       'courses_incomplete': ic,
                       'projects': projects,
                       'upload_url': upload_url,
                       'errors': {}}

            self.render(template, context)
        else:
            self.redirect('/logout')
开发者ID:nitishparkar,项目名称:udacityplus,代码行数:58,代码来源:profile.py

示例12: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
    def post(self):
        params = self.get_params(["username", "email", "password"])
        user = User.save(*params)

        if user:
            log_token = aut.create_and_save_log_token(user)
            self.set_cookies({'username':user.username, 'log_token':log_token})
            self.redirect("/")
        else:
            self.redirect("/signup")
开发者ID:ArslanRafique,项目名称:udacityplus,代码行数:12,代码来源:signup.py

示例13: post_register

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
def post_register():
    form = RegisterForm()
    if form.validate_on_submit():
        email_hash = md5.new(form.email.data.strip().lower()).hexdigest()
        user = User(email=form.email.data, email_hash=email_hash)
        user.password = generate_password_hash(form.password.data)
        user.registered = True

        '''
        # Create a stripe customer
        stripe.api_key = app.config['STRIPE_SECRET_KEY']
        customer = stripe.Customer.create(email=user.email)
        user.stripe_id = customer.id
        '''

        user.save()
        login_user(user)
        flash("Successfully registered")
        return redirect(url_for("index"))
    return render_template('register.html', form=RegisterForm())
开发者ID:di,项目名称:daywrite,代码行数:22,代码来源:__init__.py

示例14: testSave

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
 def testSave(self):
     email = '[email protected]'
     user_combos = []
     for k, v in uv.iteritems():
         for p, t in pv.iteritems():
             u = User.save(k, email, p)
             if u:
                 r = u.key.get()
                 if r:
                     self.assertEqual(r.username == k, v and t, "{}".format(k, p))
                     user_combos.append(r)
     self.assertEqual(len(user_combos), 2, "Should contain 2 users - per current test data (check if changed)")
开发者ID:Ramesh7128,项目名称:udacityplus,代码行数:14,代码来源:user_test.py

示例15: post

# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import save [as 别名]
    def post(self):
        #TODO: works with non-matching passwords, it shouldn't
        params = self.get_params(["username", "email", "password", "password_confirm"])
        user = User.save(*params)

        if user:
            log_token = aut.create_and_save_log_token(user)
            self.set_cookies({'username':user.username, 'log_token':log_token})
            self.redirect("/")
        else:
            _, errors = valid(*params)
            self.render("signup.html", {'errors': errors})
开发者ID:Ramesh7128,项目名称:udacityplus,代码行数:14,代码来源:signup.py


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