本文整理汇总了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
示例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'
示例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')
示例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)
示例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)
示例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('/')
示例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)
示例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()
示例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
示例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}
示例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)
示例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) })
示例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
示例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()
示例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()