本文整理汇总了Python中User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.password方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_user
# 需要导入模块: import User [as 别名]
# 或者: from User import password [as 别名]
def new_user(request):
"""Add a new user to the system manually."""
rdict = request.params
u = User()
u.username = unicode(rdict.get('username'))
u.email = unicode(rdict.get('email'))
passwd = get_random_word(8)
u.password = passwd
u.activated = True
u.is_admin = False
u.api_key = User.gen_api_key()
try:
DBSession.add(u)
DBSession.flush()
# We need to return the password since the admin added the user
# manually. This is only time we should have/give the original
# password.
ret = dict(u)
ret['random_pass'] = passwd
return _api_response(request, ret)
except IntegrityError, exc:
# We might try to add a user that already exists.
LOG.error(exc)
request.response.status_int = 400
return _api_response(request, {
'error': 'Bad Request: User exists.',
})