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


Python user.User类代码示例

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


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


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