本文整理汇总了Python中rfk.database.base.User.add_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.add_user方法的具体用法?Python User.add_user怎么用?Python User.add_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rfk.database.base.User
的用法示例。
在下文中一共展示了User.add_user方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import add_user [as 别名]
def setUp(self):
rfk.init()
rfk.database.init_db("sqlite://")
setup_settings()
try:
self.user = User.add_user('teddydestodes', 'roflmaoblubb')
self.other_user = User.add_user('test', 'test')
except UserNameTakenException:
pass
rfk.database.session.commit()
示例2: setup_default_user
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import add_user [as 别名]
def setup_default_user(username, password):
users = [User.add_user(username, password)]
for user in users:
rfk.database.session.add(user)
user.add_permission(code='manage-liquidsoap')
user.add_permission(code='manage-relays')
user.add_permission(code='admin')
print "[users] Added %s" % user.username
rfk.database.session.commit()
示例3: copy_users
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import add_user [as 别名]
def copy_users():
streamer = oldsession.query(Streamer).yield_per(50)
for olduser in streamer:
print olduser.username
if User.get_user(olduser.username) is None:
user = User.add_user(olduser.username, olduser.password)
rfk.database.session.add(user)
rfk.database.session.flush()
rfk.database.session.commit()
示例4: setUp
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import add_user [as 别名]
def setUp(self):
rfk.init()
rfk.database.init_db("sqlite://")
app.template_folder = '../templates/'
app.static_folder = '../static/'
app.static_url_path = '/static'
self.app = app.test_client()
user_1 = User.add_user('teddydestodes', 'roflmaoblubb')
user_2 = User.add_user('loom', 'bestes')
key_1 = ApiKey(application='app_1', description='key_1', user=user_1)
key_1.gen_key()
self.key_1 = key_1.key
key_2 = ApiKey(application='app_2', description='key_2', user=user_2, flag=ApiKey.FLAGS.DISABLED)
key_2.gen_key()
self.key_2 = key_2.key
rfk.database.session.add(key_1, key_2)
rfk.database.session.commit()
示例5: register
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import add_user [as 别名]
def register():
form = register_form(request.form)
if request.method == "POST" and form.validate():
try:
user = User.add_user(form.username.data, form.password.data)
if form.email.data:
user.mail = form.email.data
session.commit()
except UserNameTakenException:
form.username.errors.append('Username already taken!')
return render_template("register.html", form=form)
示例6: register
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import add_user [as 别名]
def register():
form = register_form(request.form)
if request.method == "POST" and form.validate():
try:
user = User.add_user(form.username.data, form.password.data)
if form.email.data:
user.mail = form.email.data
rfk.database.session.commit()
flash(gettext('Registration successful. You can now login'), 'success')
return redirect(url_for("login"))
except UserNameTakenException:
form.username.errors.append(gettext('Username already taken!'))
return render_template("register.html", form=form, TITLE='Register')