• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python User.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

def main():
    print 'Hello World'  
    myDB = MysqlPython('thinkman-wang.com', 'thinkman', 'Ab123456', 'db_thinknews')
    
    szSql = 'select * from user'
    result = myDB.select_advanced(szSql)

    for obj in result :
        user = User()
        user.id, user.user_name, user.password = obj
        
        print("%d | %s | %s" % (user.id, user.user_name, user.password))
    
    lstUser = get_all_users()
    for user in lstUser :
        print("%d | %s | %s" % (user.id, user.user_name, user.password))
    
    lstUser = get_all_user_from_pool();
    for user in lstUser :
        print("%d | %s | %s" % (user.id, user.user_name, user.password))   
    
    print obj2json(lstUser)
    
    user = login("18621675203", "a0a475cf454cf9a06979034098167b9e")
    
    if (user != None):
        print obj2json(user)
    else:
        print("login failed")
        
    szToken = ("%s%d" % ("a0a475cf454cf9a06979034098167b9e", int(time.time())))
    print(hashlib.md5(szToken).hexdigest())
开发者ID:ThinkmanWang,项目名称:python,代码行数:32,代码来源:main.py


示例2: create_user

	def create_user(self):
		u = User(_DBCON)
		u.email = self.EMAIL
		u.password = self.PASSWORD
		u.save()

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


示例3: change_password_post

def change_password_post():
	random_token = request.form.get('change-password-random-token', '')
	p_c_r = Password_Change_Requests.select_by_id(random_token, 1)

	if request.is_xhr and len(p_c_r) is not 0 and Password_Change_Requests.is_valid_random_token(p_c_r[0]['datetime']):
		p_c_r = p_c_r[0]
		new_password = request.form.get('change-password-new-password', '')
		confirm_new_password = request.form.get('change-password-confirm-new-password', '')
		language = session.get('language', 'en')

		error_list = list()

		if not User.is_password_valid(new_password):
			error_list.append(strings.STRINGS[language]['INVALID_PASSWORD'])

		if new_password != confirm_new_password:
			error_list.append(strings.STRINGS[language]['PASSWORD_NO_MATCH'])

		if len(error_list) is not 0:
			return make_response(jsonify(error_list = error_list), 400)
		else:
			User.update_password(p_c_r['user_id'], new_password)
			Password_Change_Requests.delete(p_c_r['user_id'])

			session['user_logged_id'] = p_c_r['user_id']

			username = User.select_by_id(p_c_r['user_id'], 1)[0]['username']

			return jsonify(url = '/profile/' + username)
	else:
		return redirect('/404')
开发者ID:tayllan,项目名称:anaddventure,代码行数:31,代码来源:Generic.py


示例4: index

def index():
    e = bottle.request.POST.get('email')
    p1 = bottle.request.POST.get('password1')
    p2 = bottle.request.POST.get('password2')
        
    if e and p1 and p2:
        if p1 != p2:
            return bottle.template('register', error='The passwords do not match', email=e, password1=p1, password2=p2)
        else:
            u = User(_DBCON, email=e, password=p1)
            if u._id:
                return bottle.template('register', error='An account already exists for that email address', email=e, password1=p1, password2=p2)
            else:
                u.save()
                e = Email(recipient=e)
                e.send('Places accounts activation', '<a href="%s/activate/%s">Activate</a>' % (settings.BASEURL, u.token))
                return bottle.redirect('/success')
                
                
    else:
        vd = {
            #'date':datetime.datetime.now().strftime('%Y'),
            'baseurl':settings.BASEURL,
        }
        return bottle.template('register', error='Please complete the form', email=e or '', password1=p1 or '', password2=p2 or '', vd=vd)
开发者ID:iamcm,项目名称:consensus,代码行数:25,代码来源:app.py


示例5: post

 def post(self, *args, **kwargs):
     user_uuid = self.get_argument('uuid', '')
     user = User.by_uuid(user_uuid)
     if user is not None:
         errors = []
         username = self.get_argument('username', None)
         password = self.get_argument('password', None)
         if password is not None:
             if 12 <= len(password) <= 100:
                 self.change_user_password(user)
             else:
                 errors.append("Password invalid length (12-100)")
         if username is not None and username != user.username:
             if 3 <= len(username) <= 15:
                 if User.by_username(username) is None:
                     user.username = username
                     dbsession.add(user)
                     dbsession.flush()
                 else:
                     errors.append("Username already exists")
             else:
                 errors.append("Username is an invalid length (3-15)")
         self.render("admin/manage_users.html", errors=errors)
     else:
         self.render("admin/manage_users.html",
             errors=["User does not exist"]
         )
开发者ID:DJHartley,项目名称:The-Planetary-Assault-System,代码行数:27,代码来源:AdminHandlers.py


示例6: get

    def get(self, *args, **kwargs):
        self.errors = []

        # перезагружаем конфигурацию приложения
        self.application.loadConfiguration()

        self.removeDBSessions()
        # миграция БД
        password = None
        try:
            connection = self.getDBSession()
            migrate(connection = connection)
        except BaseException as exception:
            self.errors.append(u'Ошибка при миграции БД: ' + exception.message)
        else:
            # create admin user
            password = hashlib.sha256(str(time.time())).hexdigest()[5:11]
            user = User()
            user.fullname = 'Admin'
            user.login = 'admin'
            user.password = hashlib.sha256(password).hexdigest()
            user.role = User.ROLE_ADMIN
            try:
                connection.merge(user)
                connection.commit()
            except BaseException as exception:
                self.errors.append(u'Ошибка при создани пользователя: ' + exception.message)
            else:
                self.application.isInstalled = True

        self.render('install/end.jinja2', {'errors': self.errors, 'admin_pass': password})
开发者ID:x100up,项目名称:analystics,代码行数:31,代码来源:InstallController.py


示例7: contribution_requests_refuse

def contribution_requests_refuse():
	contribution_request_id = request.form.get('contribution_request_id', -1)
	contribution_request = Contribution_Request.select_by_id(contribution_request_id, 1)

	if len(contribution_request) is not 0:
		contribution_request = contribution_request[0]
		tale = Tale.select_by_id(contribution_request['tale_id'], 1)[0]

		if tale['creator_id'] is session.get('user_logged_id', None):
			Contribution_Request.update_was_accepted(contribution_request['id'], False)
			Tale.update_contribution_request_count(contribution_request['tale_id'], -1)

			creator = User.select_by_id(tale['creator_id'], 1)[0]
			contributor = User.select_by_id(contribution_request['user_id'], 1)[0]

			email_object = strings.construct_contribution_request_refused_email_object(
				session.get('language', 'en'),
				tale,
				creator,
				contributor,
				contribution_request['id']
			)

			aux.send_email_to_followers(tale['id'], email_object['title'], email_object['body'])

			return redirect('/tale/' + str(contribution_request['tale_id']) + '/0')
		else:
			return redirect('/404')
	else:
		return redirect('/404')
开发者ID:tayllan,项目名称:anaddventure,代码行数:30,代码来源:Generic.py


示例8: invite_post

def invite_post(tale_id):
	username = request.form.get('invite-username', '')
	user = User.select_by_email(username, 1)
	tale = Tale.select_by_id(tale_id, 1)

	if len(user) is 0:
		user = User.select_by_full_username(username, 1)

	if len(user) is not 0 and len(tale) is not 0 and session.get('user_logged_id', None) is tale[0]['creator_id']:
		user = user[0]
		tale = tale[0]
		new_invitation = Invitation(session['user_logged_id'], user['id'], tale_id)
		new_invitation.insert()

		creator = User.select_by_id(tale['creator_id'], 1)[0]

		email_object = strings.construct_tale_invitation_email_object(
			session.get('language', 'en'),
			user,
			tale,
			creator
		)

		aux.send_email(email_object['title'], user['email'], email_object['body'])

	return redirect('/tale/' + str(tale_id) + '/0')
开发者ID:tayllan,项目名称:anaddventure,代码行数:26,代码来源:Generic.py


示例9: testValidEmail

    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,代码行数:7,代码来源:user_test.py


示例10: init_QA

def init_QA():
    is_student_exist = False
    is_lecturer_exist = False
    qa_student = User(username='qa_student', name='Student QA', avatar_url='http://ava.com', email='[email protected]',
                   isLecturer=False, accessToken='student_token_', seToken='_QA_TOKEN_TEST_STUDENT')
    qa_lecturer = User(username='qa_lecturer', name='Student QA', avatar_url='http://ava.com', email='[email protected]',
                   isLecturer=True, accessToken='student_token_', seToken='_QA_TOKEN_TEST_LECTURER')
    query = User.all().filter('username =', qa_student.username)
    for u in query.run():
        is_student_exist = True
        u.isLecturer = qa_student.isLecturer
        u.seToken = qa_student.seToken
        u.campuses_id_list = []
        u.classes_id_list = []
        db.put(u)

    query = User.all().filter('username =', qa_lecturer.username)
    for u in query.run():
        is_lecturer_exist = True
        u.isLecturer = qa_lecturer.isLecturer
        u.seToken = qa_lecturer.seToken
        u.campuses_id_list = []
        u.classes_id_list = []
        db.put(u)

    if not is_lecturer_exist:
        db.put(qa_lecturer)
    if not is_student_exist:
        db.put(qa_student)

    return Response(status=200)
开发者ID:jce-il,项目名称:SE-Hub,代码行数:31,代码来源:API.py


示例11: setUp

    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,代码行数:8,代码来源:message_test.py


示例12: post

 def post(self, *args, **kwargs):
     ''' Attempts to create an account, with shitty form validation '''
     # Check user_name parameter
     try:
         user_name = self.get_argument('username')
     except:
         self.render('public/registration.html', errors = 'Please enter a valid account name')
         
     # Check handle parameter
     try:
         handle = self.get_argument('handle')
     except:
         self.render('public/registration.html', errors = 'Please enter a valid handle')
     
     # Check password parameter
     try:
         password1 = self.get_argument('pass1')
         password2 = self.get_argument('pass2')
         if password1 != password2:
             self.render('public/registration.html', errors = 'Passwords did not match')
         else:
             password = password1
     except:
         self.render('public/registration.html', errors = 'Please enter a password')
     
     # Check recaptcha
     try:
         response = captcha.submit(
             self.get_argument('recaptcha_challenge_field'),
             self.get_argument('recaptcha_response_field'),
             self.application.settings['recaptcha_private_key'],
             self.request.remote_ip,)
     except:
         self.render('public/registration.html', errors = "Please fill out recaptcha!")
 
     # Create account
     if User.by_user_name(user_name) != None:
         self.render('public/registration.html', errors = 'Account name already taken')
     elif user_name == handle:
         self.render('public/registration.html', errors = 'Account name and hacker name must differ')
     elif User.by_display_name(handle) != None:
         self.render('public/registration.html', errors = 'Handle already taken')
     elif not 0 < len(password) <= 7:
         self.render('public/registration.html', errors = 'Password must be 1-7 characters')
     elif not response.is_valid:
         self.render('public/registration.html', errors = 'Invalid Recaptcha!')
     else:
         char_white_list = ascii_letters + digits
         user_name = filter(lambda char: char in char_white_list, user_name)
         display_name = filter(lambda char: char in char_white_list, handle)
         user = User(
             user_name = unicode(user_name),
             display_name = unicode(display_name),
             password = password
         )
         self.dbsession.add(user)
         self.dbsession.flush()
     self.redirect('/login')
开发者ID:xaelek,项目名称:RootTheBox,代码行数:58,代码来源:RootHandlers.py


示例13: new_users

def new_users():
    users = json.loads(request.data)
    users = users['users']
    session = Session()

    for user in users:
        User.get_or_create_temp(session, user)

    return jsonify({'received': 'true'})
开发者ID:TomDunn,项目名称:RedditGraph,代码行数:9,代码来源:application.py


示例14: activate_token

    def activate_token(self, token):
        u = User(_DBCON)
        if u.activate(token):
            self._login_user(u)

        else:
            self.viewdata.update({"error": "The token does not match any account that is pending activation"})

            return self._template("error")
开发者ID:iamcm,项目名称:jug,代码行数:9,代码来源:AuthController.py


示例15: test_activate_user_good_token

	def test_activate_user_good_token(self):
		self.create_user()

		user = _DBCON.User.find_one()

		u = User(_DBCON)
		self.assertTrue(u.activate(user['token']))
		self.assertTrue(u.valid)
		self.assertTrue(u.email == self.EMAIL)
开发者ID:iamcm,项目名称:bottle-inventory,代码行数:9,代码来源:user_test.py


示例16: get

    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,代码行数:56,代码来源:profile.py


示例17: test_password_is_still_the_same_after_user_instance_being_saved

	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,代码行数:10,代码来源:user_test.py


示例18: create_user

def create_user():
    user = User.by_handle("HacKer")
    if user is None:
        user = User()
        user.handle = "HacKer"
        user.password = "TestPassword"
        user.bank_password = "Test123"
        dbsession.add(user)
        dbsession.commit()
    return user
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:10,代码来源:Helpers.py


示例19: register

def register():
    if request.method=="GET":
        return render_template("register.html")
    elif request.method=="POST":
        user_name=request.form["username"]
        password=request.form["password"]
        user=User(user_name,password,time.strftime("%Y-%m-%d %T"),None)
        User.add(user)
        session["user"]=serials.getDict(user)
        return redirect(url_for("vip.index"))
开发者ID:isaced,项目名称:ComSay,代码行数:10,代码来源:index.py


示例20: create_user

    def create_user(self):
        ''' Add user to the database '''
        if User.by_handle(self.get_argument('handle', '')) is not None:
            raise ValidationError("This handle is already registered")
        if self.get_argument('pass1', '') != self.get_argument('pass2', ''):
            raise ValidationError("Passwords do not match")
        user = User()
        user.handle = self.get_argument('handle', '')
        user.password = self.get_argument('pass1', '')
        user.bank_password = self.get_argument('bpass', '')
        user.name = self.get_argument('playername', '')
        user.email = self.get_argument('email','')
        team = self.get_team()
        self.dbsession.add(user)
        self.dbsession.add(team)
        self.dbsession.commit()

         # Avatar
        avatar_select = self.get_argument('user_avatar_select', '')
        if avatar_select and len(avatar_select) > 0:
            user._avatar = avatar_select
        elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
            user.avatar = self.request.files['avatar'][0]['body']
        team.members.append(user)
        if not options.teams:
            if avatar_select and len(avatar_select) > 0:
                team._avatar = avatar_select
            elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
                team.avatar = self.request.files['avatar'][0]['body']  
        self.dbsession.add(user)
        self.dbsession.add(team)
        self.dbsession.commit()  
        self.event_manager.user_joined_team(user)
        return user
开发者ID:moloch--,项目名称:RootTheBox,代码行数:34,代码来源:PublicHandlers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python account.Account类代码示例发布时间:2022-05-27
下一篇:
Python Team.Team类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap