本文整理汇总了Python中assembl.models.User.username_p方法的典型用法代码示例。如果您正苦于以下问题:Python User.username_p方法的具体用法?Python User.username_p怎么用?Python User.username_p使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assembl.models.User
的用法示例。
在下文中一共展示了User.username_p方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_user
# 需要导入模块: from assembl.models import User [as 别名]
# 或者: from assembl.models.User import username_p [as 别名]
def admin_user(request, test_session):
"""A User fixture with R_SYSADMIN role"""
from assembl.models import User, Username, UserRole, Role
u = User(name=u"Mr. Administrator", type="user",
verified=True, last_assembl_login=datetime.utcnow())
u.username_p = "mr_admin_user"
from assembl.models import EmailAccount
account = EmailAccount(email="[email protected]", profile=u, verified=True)
test_session.add(u)
test_session.add(account)
r = Role.get_role(R_SYSADMIN, test_session)
ur = UserRole(user=u, role=r)
test_session.add(ur)
test_session.flush()
uid = u.id
def fin():
print "finalizer admin_user"
# I often get expired objects here, and I need to figure out why
user = test_session.query(User).get(uid)
user_role = user.roles[0]
test_session.delete(user_role)
test_session.delete(account)
test_session.delete(user.username)
test_session.delete(user)
test_session.flush()
request.addfinalizer(fin)
return u