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

Python user.User类代码示例

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

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



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

示例1: register

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


示例2: post

    def post(self):
        self.set_header("Content-Type", "application/json")

        try:
            email = str(self.get_argument("email"))
            password = str(self.get_argument("password"))
            password2 = str(self.get_argument("password2"))
        except:
            self.write(json.dumps("邮箱、密码、确认密码均为必填项!"))
            return

        if password != password2:
            self.write(json.dumps("两次输入的密码不一致!"))
            return

        has_user = User.get_user_by_email(email)
        if not has_user:
            try:
                # TODO baitao.ji 改造为发送验证邮件后才插入数据库中的用户表
                User.create_user("无名氏", email, password)
                self.write(json.dumps("OK"))
            except:
                self.write(json.dumps("保存用户时数据库超时,请稍后重试!"))
        else:
            self.write(json.dumps("已存在该邮箱, 请尝试其他邮箱或用该邮箱登录!"))
            return
开发者ID:dreambt,项目名称:healthnote,代码行数:26,代码来源:default.py


示例3: list

 def list(self):
     id = int(self.get_argument('id',0))
     name = self.get_argument('name','')
     orgid = int(self.get_argument('orgid',0))
     page = int(self.get_argument('pageNum',1))
     psize = int(self.get_argument('numPerPage',20))
     count = User.mgr().Q().count()
     page_count = (count+psize-1)/psize
     q = User.mgr().Q()
     id and q.filter(id=id)
     name and q.extra("name LIKE '%%%s%%'"%name)
     if orgid:
         org = Orgnization.mgr().one(orgid)
         q.extra("orgid in (%s)"%','.join([str(i.id) for i in org.children()]))
     users = q[(page-1)*psize:page*psize]
     for u in users:
         u.full_org_name = '-'.join([o.name for o in u.org_path()])
     orgs = Orgnization.mgr().Q()
     self.render('user/user_list.html',
                 name = name,
                 orgid = orgid,
                 page = page,
                 psize=psize,
                 count=count,
                 page_count=page_count,
                 users=users,
                 orgs = orgs)
开发者ID:appleface2050,项目名称:yuezhang_logstat,代码行数:27,代码来源:user.py


示例4: post

    def post(self):
        """
        Login in with a Facebook account if the user has existed
        Otherwises, create a new user with information from Facebook
        """
        args = fbUserParser.parse_args()
        fb_id = args['fbid']
        fb_token = args['fbtoken']
        if fb_id is None or fb_token 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)

        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()

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


示例5: authenticate

    def authenticate(self, request):
        email = request.user_email
        validate_email(email)
        team_key = request.team_key
        user = User.find_user_by_email(email, team_key)

        if team_key:
            team_secret = request.team_secret
            validate_team_secret(team_secret)

            display_name = request.display_name
            image_url = request.user_image_url

            if not user:
                user = User.insert_user(email=email, username=display_name, account_type=team_key, image_url=image_url)
                community = Community.getCommunityFromTeamKey(team_key)
                UserRole.insert(user, community)
            elif (display_name != user.display_name) or (image_url != user.image_url):
                User.update_user(user=user, email=email, username=display_name, account_type=team_key, image_url=image_url)
            if not Community.authenticate(team_key, md5(team_secret)):
                raise endpoints.UnauthorizedException("Authentication failed. Team key and secret are not matched.")
        elif user.auth_source == AuthSourceType.ANNO:
            password = request.password
            validate_password(password)
            if not user:
                raise endpoints.NotFoundException("Authentication failed. User account " + email + " doesn't exist.")
            if not User.authenticate(email, md5(password)):
                raise endpoints.UnauthorizedException("Authentication failed. Email and password are not matched.")
        else:
            raise endpoints.ForbiddenException("Account for '%s' is Google or Facebook OAuth account." % email)

        return UserMessage(id=user.key.id(), display_name=user.display_name)
开发者ID:usersource,项目名称:anno,代码行数:32,代码来源:account_api.py


示例6: _process_users

    def _process_users(self, session, **kwargs):
        modified_voters = set()
        new_user = None
        if "new_voter" in kwargs and kwargs["new_voter"]:
            new_user = User(name=kwargs["new_voter"])
            new_user.put()

            user_by_session = UserBySession(user=new_user, session=session)
            user_by_session.put()

        voter_keys = []
        if "voter_key" in kwargs:
            voter_keys = [kwargs["voter_key"]]
            if isinstance(kwargs["voter_key"], list):
                voter_keys = voter_keys[0]

            if "voter_name" in kwargs and not isinstance(kwargs["voter_name"], list):
                kwargs["voter_name"] = [kwargs["voter_name"]]

            for i in range(len(voter_keys)):
                voter = User.get(voter_keys[i])
                voter.name = kwargs["voter_name"][i]
                voter.put()
                modified_voters.add(voter)

        return (new_user, modified_voters)
开发者ID:mtambos,项目名称:brainstormcracy,代码行数:26,代码来源:brainstorming_session.py


示例7: post

 def post(self):
     name = self.get_argument('name', '')
     email = self.get_argument('email', '')
     password = self.get_argument('password', '')
     if not name or len(name) > 15:
         self.render('join.html', error=111, name=name, email=email)
         return
     match = re.search(r'[\w.-][email protected][\w.-]+', email)
     if not match:
         self.render('join.html', error=112, name=name, email=email)
         return
     if not password:
         self.render('join.html', error=110, name=name, email=email)
         return
     user = User.get_by_email(email)
     if user:
         self.render('join.html', error=113, name=name, email=email)
         return
     user = User.new(name, email)
     if user:
         user.update_password(encrypt(password))
     else:
         self.render('join.html', error=114)
     self.set_secure_cookie('user', user.id, expires_days=30)
     self.redirect(self.get_argument('next', '/'))
开发者ID:Daniel7725,项目名称:diggit,代码行数:25,代码来源:login.py


示例8: test_email_is_existed

def test_email_is_existed():
    email = "[email protected]"
    result = User.email_is_existed(email)
    assert result == True
    email = "[email protected]"
    result = User.email_is_existed(email)
    assert result == False
开发者ID:zivsu,项目名称:weblog,代码行数:7,代码来源:test_user.py


示例9: init_db

def init_db():
    from model.user import User
    from model.url import URL
    from model.cata import Cata
    from model.mod_log import ModLog
    from misc.const import d_cata, d_source

    # 创建表
    db.create_tables([User, URL, Cata, ModLog])

    # 新建用户
    data = dict(
        user="admin",
        name="admin",
        pwd=hashlib.md5('admin').hexdigest(),
    )
    User.create(**data)

    # 创建交叉表
    for k in d_cata.keys():
        for k1 in d_source.keys():
            c = Cata.select().where(Cata.cata == k, Cata.source == k1)
            if not c:
                d_ = dict(
                    cata=k,
                    source=k1,
                )
                Cata.create(**d_)
开发者ID:tonghuashuai,项目名称:sth,代码行数:28,代码来源:_base.py


示例10: POST

	def POST(self):
		data = web.input()
		username, password, email = data.username, data.password, data.email
		user = User()
		if user.register(username, password, email):
			return render.login()
		return render.register()
开发者ID:top,项目名称:python,代码行数:7,代码来源:mis.py


示例11: __init__

    def __init__(self):

        db = Database('database')

        if db .root is None:

            root = Persistent()
            root.list_of_users = []
            db.elect (root)
            transaction.commit()

            checkout(db.root)

            self.list_of_users = db.root.list_of_users

            # Creating a user default to make easy the development
            user = User('Fulano', '[email protected]', 'pwd', "uid")

            document = Document("My document", ".txt", "I think to myself... what a wonderful world!", "uid", user.folder.id)
            document.id = "did"
            user.folder.id = "fid"
            user.add_document(user.folder.id, document)

            db.root.list_of_users.append(user)
            db.root.list_of_users = self.list_of_users

            transaction.commit()

            checkout(db .root)

            self.list_of_users = db .root.list_of_users
        else:
            self.list_of_users = db.root.list_of_users
        super(UserRepository, self).__init__()
开发者ID:SilvaMatteus,项目名称:SiWebClient,代码行数:34,代码来源:user_repository.py


示例12: save_user_info

	def save_user_info(self, cmd_params):
		username = cmd_params['username']['value']
		password = cmd_params['password']['value']
		experience = cmd_params['experience']['value']
		level = cmd_params['level']['value']

		user = User(username, password)
		dbconn = DBConnection(conf.DB_USER)
		cursor = dbconn.get_cursor()
		uid = user.get_uid()

		user_info = None
		if uid in cursor.keys():
			user_info = cursor[uid]

		if not user_info:
			user_info = user.pack_user_info()
		
		user_info['experience'] = experience
		user_info['level'] = level
		cursor[uid] = user_info
		dbconn.write_back(cursor)

		reply_info = [('error', False, TYPE.BOOLEAN)]
		return reply_info
开发者ID:JumsphenmXu,项目名称:code,代码行数:25,代码来源:server.py


示例13: signup_base

def signup_base():
    errors = {}
    try:
        email = request.form['email']
        password = request.form['password']
        try:
            confirm = request.form['confirm']
        except KeyError:
            confirm = password
        if not password == confirm:
            errors['password'] = _(u"Inconsistent password twice.")
        if not validate_email(email):
            errors['email'] = _(u"please check your email address again")
        if len(password) < 6:
            errors['password'] = _(u"Your password is too short. At least 6 characters.")
    except KeyError:
        errors['KeyError'] = _(u'key error')

    if not errors:
        user = User.query.filter_by(email=email).first()
        if user:
            errors['email'] = _(u'this email has been used')
        else:
            user = User(email,pack_password(password))
            user.commit()
            detail = UserDetail(user)
            detail.commit()
            login_user(user)
            refresh()
    return errors
开发者ID:eavae,项目名称:mlang,代码行数:30,代码来源:signup.py


示例14: get

 def get(self):
     user = User()
     user.email = ""
     user.password = ""
     user.name=""
     user.password_confirm = ""
     return self.render('setting_add_user.html', user_name="", user=user, errors={})
开发者ID:hazelor,项目名称:tobacco_monitor,代码行数:7,代码来源:auth.py


示例15: register_handler

def register_handler():
    username = request.form['username']
    password = request.form['password']
    email = session['email']
    errors = []

    if not re.match('^[a-z0-9]+$', username):
        errors.append("The submitted username contains non-alphanumeric characters")
    if User.query.filter(User.email == email).first():
        errors.append("A user with the same email already exists")
    if not User.strong_password(password):
        errors.append("Your password must contain a mix of letters and numerical characters and be at least 6 characters long")

    # Checking if a user exists in RabbitMQ OR in our db
    try:
        pulse_management.user(username=username)
        in_rabbitmq = True
    except PulseManagementException:
        in_rabbitmq = False

    if in_rabbitmq:
        errors.append("A user with the same username already exists in Pulse")
    if User.query.filter(User.username == username).first():
        errors.append("A user with the same username already exists in our database")
    if errors:
        signup_error = "{0}.".format(', '.join(errors))
        return render_template('register.html', email=email, signup_error=signup_error)

    user = User.new_user(email=email, username=username, password=password, management_api=pulse_management)
    db_session.add(user)
    db_session.commit()

    return render_template('confirm.html')
开发者ID:ewongbb,项目名称:pulseguardian,代码行数:33,代码来源:web.py


示例16: create

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


示例17: post

 def post(self):
     password1 = self.get_argument('password1', '')
     password2 = self.get_argument('password2', '')
     username = self.current_user().username
     next = self.get_argument("next", "")
     error = False
     if len(password1) < 3 or len(password1) > 18:
         error = True
         self.messages.error('密码长度必须大于3小于18!')
     if len(password2) < 3 or len(password2) > 18:
         error = True
         self.messages.error('密码长度必须大于3小于18!')
     if password1 != password2:
         error = True
         self.messages.error('您输入的密码不一致!')
     if not User.exist(username):
         error = True
         self.messages.error('用户不存在!')
     if not error:
         User.update_pass(username, password1)
         self.messages.success('账户密码修改成功!')
         if next:
             return self.redirect(next)
         self.redirect('/')
     else:
         if next:
             return self.redirect(next)
         self.redirect('/')
开发者ID:jtwmyddsgx,项目名称:1024,代码行数:28,代码来源:user.py


示例18: pull_user_info

def pull_user_info(openid, web_access_token=None):
    if web_access_token:
        pull_user_info_url = wxconfig.pull_user_info_url.format(web_access_token, openid)
        http_client = AsyncHTTPClient()
        response = yield http_client.fetch(pull_user_info_url)
        logging.debug(response.body.decode())
        user_dict = json.loads(response.body.decode())
        user = dict_to_model(User, user_dict, ignore_unknown=True)
    else:
        user = User(openid='openid')
    user_id = None
    try:
        _user = dbutil.do(User.get, User.openid == openid)
        user_id = _user.get_id()
        exists = True
    except DoesNotExist:
        exists = False
    if exists:
        assert user_id
        user.set_id(user_id)
        user.updatetime = datetime.datetime.now()
    else:
        user.createtime = datetime.datetime.now()
    yield dbutil.do(user.save)
    user = yield dbutil.do(User.get, User.openid == openid)
    return model_to_dict(user)
开发者ID:zy4290,项目名称:qilaihi.club,代码行数:26,代码来源:wxutil.py


示例19: post

    def post(self):
        username = self.get_argument('username', '')
        email = self.get_argument('email', '')
        password = self.get_argument('password', '')

        if not username or len(username) > 15:
            self.render('home/register.html', error=111, username=username, email=email)
            return
        match = re.search(r'[\w.-][email protected][\w.-]+', email)
        if not match:
            self.render('home/register.html', error=113, username=username, email=email)
            return
        if not password:
            self.render('home/register.html', error=110, username=username, email=email)
            return

        user = User.get_by_username(username)
        if user:
            self.render('home/register.html', error=112, username=username, email=email)
            return

        user = User.get_by_email(email)
        if user:
            self.render('home/register.html', error=114, username=username, email=email)
            return

        #走代理获取ip方式
        reg_ip = self.request.headers['X-Real-Ip']
        user = User.new(username, email, password, reg_ip)
        if user:
            self.set_secure_cookie('user_id', str(user.user_id), expires_days=30)
            self.redirect(self.get_argument('next', '/'))
        else:
            self.render('home/register.html', error=115)
开发者ID:ListFranz,项目名称:PyCMS-Tornado,代码行数:34,代码来源:login.py


示例20: test_user_deletes_task

def test_user_deletes_task():
    task_name = 'write an email'
    user = User('username', [Reward('kisses', 1000)], [SnailTask(task_name)], [], todays_empty_purse)

    user.delete_task(task_name)

    tools.assert_false(user.has_task_named(task_name))
开发者ID:rosatolen,项目名称:velocity,代码行数:7,代码来源:user_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python zsite.Zsite类代码示例发布时间:2022-05-27
下一篇:
Python testfile.TestFile类代码示例发布时间: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