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


Python User类代码示例

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


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

示例1: test_get_by_id

    def test_get_by_id(self):
        """Get user by ID."""
        user = User('foo', '[email protected]')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
开发者ID:abdza,项目名称:cookiecutter-flask,代码行数:7,代码来源:test_models.py

示例2: connect

	def connect(self):
		from ContentMgmt import ContentMgmt
		import User
		User.init_graphics()
		from User import interface_user

		self.user = interface_user.connect()
		if self.user != None:
			from db import db
			from University import University
			print 'access granted'
			self.connected = True
			self.user.settings.load_settings()
			def query(db, empty):
				return db.session.query(University).get(1)
			self.university = db.session_query(query, None,
			    'Timetableasy init : query(University).get(1)')
			self.contentmgr = ContentMgmt()
			# XXX what to do with that ?
			#if db.status == False:
			#	self.contentmgr.status_bar.add_action('icon', 9)
			self.contentmgr.status_bar.add_action('icon', 2)
			self.contentmgr.status_bar.set_connection_status(1)
			self.contentmgr.status_bar.check_date_display()
			# XXX first load of rights
			if (not self.user.is_admin()):
				self.contentmgr.menubar.admin.hide()
			self.contentmgr.show()
		else:
			print 'access denied'
开发者ID:SBillion,项目名称:timetableasy,代码行数:30,代码来源:Timetableasy.py

示例3: test_user_password

    def test_user_password(self, testapp):
        """ Test password hashing and checking """

        admin = User(username="admin", password="supersafepassword")

        assert admin.username == 'admin'
        assert admin.check_password('supersafepassword')
开发者ID:smeggingsmegger,项目名称:flask-cookiecutter,代码行数:7,代码来源:test_models.py

示例4: create_standard_user

  def create_standard_user(
      self
    , VIP
    , GLASSES_ID
    , PLATFORM_ID
    , HEADTRACKING_TARGET_NAME
    , WARNINGS
    ):
    _user = User()
    _user.my_constructor(self
                       , len(self.user_list)
                       , VIP
                       , GLASSES_ID
                       , HEADTRACKING_TARGET_NAME
                       , PLATFORM_ID
                       , self.navigation_list[PLATFORM_ID].trace_material)
    self.user_list.append(_user)

    # init border checker to warn user on platform
    if WARNINGS:
      if self.border_observer_list[PLATFORM_ID] == None:
        _checked_borders = [True, True, True, True]
        self.create_border_observer(_checked_borders, _user, self.navigation_list[PLATFORM_ID].platform)
      else:
        self.border_observer_list[PLATFORM_ID].add_user(_user)
开发者ID:Lockenkopf1992,项目名称:navigation-viewing-framework,代码行数:25,代码来源:ApplicationManager.py

示例5: setup_players

 def setup_players(self):
     # ask how many players
     player_count = int(raw_input("How many players?: "))
     for count in range(player_count):
         temp_user_assign = User()
         temp_user_assign.name = "Player " + str(count + 1)
         self.users.append(temp_user_assign)
开发者ID:bluemania,项目名称:Code,代码行数:7,代码来源:Game.py

示例6: post

	def post(self):
		username = self.request.get("username")
		password = self.request.get("password")
		verify = self.request.get("verify")
		email = self.request.get("email")
		has_error = False
		params = dict(username = username, email=email)
		if not valid_username(username):
			params['error_username'] = "That's not a valid username."
			has_error = True
		if not valid_password(password):
			params['error_password'] = "That's not a valid password."
			has_error = True
		if not (password == verify):		
			has_error = True
			params['error_verify'] = "Your passwords didn't match."
		if email:
			if not valid_email(email):
				params['error_email'] = "That's not a valid email."
				has_error = True

		if has_error:
			self.render('signup-form.html', **params)
		else:
			users = getByUsername(username)
			if users.count() != 0:
				params['error_user'] = "That user already exists"
				self.render('signup-form.html', **params)
			else:
				hash_password = pw_hash(password)
				u = User(username=username,password=hash_password,email=email)
				u.put()
				self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/'%str(username))
				self.redirect('/')
开发者ID:tofutie,项目名称:foodpointwatcher,代码行数:34,代码来源:SignUp.py

示例7: admin_users_add

def admin_users_add():
    user = User()
    user.id = ''
    user.firstname = ''
    user.lastname = ''
    user.email = ''
    return render_template('user.html', user=user)
开发者ID:smeggingsmegger,项目名称:flask-cookiecutter,代码行数:7,代码来源:admin.py

示例8: adduser

 def adduser(self, userkey, uname):
     """Add a user to the datastore."""
     #Check for a user with that name
     if User.get(uname) is not None:
         raise RuntimeError("Username in use")
     if User.gql("WHERE googleacct = :1", users.get_current_user()).count() > 0:
         raise RuntimeError("Account in use")
     User.(key_name=uname, userkey=userkey, uname=uname).put()
开发者ID:magisterquis,项目名称:ResistanceGameServer,代码行数:8,代码来源:register.py

示例9: new_user

def new_user(name, c):    # new user function creates a user object and builds it
    #directory = user_directory(name, c)     
    #disable deleting old directory to make a new one
    #if (file_exists(directory)):
    #    rmdir(directory)
    
    u = User(name, c)   #instantiate a user object with parameters username and user's classname  
    u.build()        #call user object method build() from User.py
    return u           # return built user object - used in Console.py 
开发者ID:av8ramit,项目名称:excelerate,代码行数:9,代码来源:Commands.py

示例10: post

 def post(self):
     args = user_parser.parse_args()
     user = User(first_name=args.first_name, last_name=args.last_name, username=args.username)
     user.set_password(args.password)
     db.session.add(user)
     db.session.commit()
     user_url = fields.Url('user_bp.user_detail', absolute=True)
     user_url = user_url.output(user_url.endpoint, {"username": user.username})
     return user, 201, {"Location": user_url}
开发者ID:Xk0nSid,项目名称:cookiecutter-flask-restful,代码行数:9,代码来源:users.py

示例11: register

def register():
    """Register new user."""
    form = RegisterForm(request.form, csrf_enabled=False)
    if form.validate_on_submit():
        User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True)
        flash('Thank you for registering. You can now log in.', 'success')
        return redirect(url_for('public.home'))
    else:
        flash_errors(form)
    return render_template('public/register.html', form=form)
开发者ID:LindaOrtega,项目名称:cookiecutter-flask,代码行数:10,代码来源:views.py

示例12: getUsers

def getUsers():
    if ('i' in request.args):
        resultados = User.listado(int(request.args['i']))
    elif ('a' in request.args):
        resultados = User.listado(0, request.args['a'])

    if (len(resultados) == 0):
        abort(404)
    else:
        return jsonify({ 'user': marshal(resultados, User.FIELDS) })
开发者ID:tinopf,项目名称:pernasferreiro.es,代码行数:10,代码来源:signboard.py

示例13: create

def create(name,pwd):
    res=User.getRes('select * from user where name=\"'+name+'\"')
    if len(res):#user已经存在
        return -1
    else:#user不存在
        User.getRes('insert into user (name,pwd,ufriends) values (\"'+name+'\",\"'+pwd+'\",\"\''+name+'\',\")')
        res=User.getRes('select * from user where name=\"'+name+'\"')
        if len(res)!=0:
            return 1
        else:
            return 0
开发者ID:ChenL1994,项目名称:TalkOnline,代码行数:11,代码来源:register.py

示例14: build

def build(install_config):
    if install_config != None:
        cleanup = Cleanup()
        session = Database.create_sqlalchemy_session_push(cleanup)
        
        Group.add(session, "owner", "Owner")
        GroupPermission.set(session, "owner", "admin", 99999999, True)

        User.add_user_account(session, install_config.OWNER_USERNAME, install_config.OWNER_PASSWORD)
        UserGroup.join(session, install_config.OWNER_USERNAME, "owner")
        session.commit()
开发者ID:luzi82,项目名称:HiSocial,代码行数:11,代码来源:_reset.py

示例15: command_guest_change_user_account_password

def command_guest_change_user_account_password(txt_user_id, txt_old_password, txt_new_password):
    cleanup = Cleanup()
    session = Database.create_sqlalchemy_session_push(cleanup)
    
    if not User.check_user_account_password(session, txt_user_id, txt_old_password):
        return hs_plugin.fail(reason="auth")
    
    User.change_password(session, txt_user_id, txt_new_password)
    session.commit()
    cleanup.clean_all();

    return hs_plugin.ok()
开发者ID:luzi82,项目名称:HiSocial,代码行数:12,代码来源:_hisocial.py


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