本文整理汇总了Python中db.User.get_by_user_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_user_id方法的具体用法?Python User.get_by_user_id怎么用?Python User.get_by_user_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.User
的用法示例。
在下文中一共展示了User.get_by_user_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_and_validate_user
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_by_user_id [as 别名]
def _get_and_validate_user(self, username, password):
user = User.get_by_user_id(username)
if user == None or not user.validate_password(password):
raise AuthenticationError(
'Username or password does not match.'
)
return user
示例2: get_user
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_by_user_id [as 别名]
def get_user(self, username):
user = User.get_by_user_id(username)
return {
'user_id': user.user_id,
'ldap_id': user.ldap_id,
'banned': user.banned,
'gets_mail': user.gets_mail,
}
示例3: get_tweets
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_by_user_id [as 别名]
def get_tweets(self, username = None, limit = 20):
if username == None:
posts = Post.get_last(limit)
else:
posts = Post.get_by_user_id(username, limit)
return map(
lambda x: {
'poster': User.get_by_user_id(x.poster_id).ldap_id,
'status_id': x.status_id
},
posts
)
示例4: do_identify
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_by_user_id [as 别名]
def do_identify(self, username, password):
nick = self._get_nick()
user = User.get_by_user_id(username)
login_error_reply = "Username or password is wrong."
if user == None:
reply = login_error_reply
else:
if user.login(self.event.source(), password):
reply = "You are now identified as %s." % user.user_id
else:
reply = login_error_reply
self._do_reply(reply)
示例5: _set_bann
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_by_user_id [as 别名]
def _set_bann(self, username, bann_status):
try:
if username[0] == '@':
bannee = User.get_by_user_id(username[1:])
else:
bannee = User.get_by_irc_id(username)
banner = User.get_by_irc_id(self.event.source())
if banner.banned:
reply = 'You are banned.'
elif not banner.admin:
reply = 'You are no admin.'
elif bannee != None:
if bannee.user_id == banner.user_id:
reply = 'You can\'t %sban yourself.' % ('' if bann_status else 'un')
else:
bannee.banned = bann_status
reply = 'You %sbanned user %s.' % ('' if bann_status else 'un', bannee.user_id)
else:
reply = 'User %s does not exist.' % username
except User.NotLoggedIn, e:
reply = str(e)
示例6: do_admin
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_by_user_id [as 别名]
def do_admin(self,username):
try:
if username[0] == '@':
user = User.get_by_user_id(username[1:])
else:
user = User.get_by_irc_id(username)
admin = User.get_by_irc_id(self.event.source())
if admin == None:
reply = 'You are no admin.'
elif not admin.admin:
reply = 'You are no admin.'
elif user != None:
if user.user_id != admin.user_id:
user.admin = not user.admin
if user.admin:
reply = 'You made %s an admin.' % user.user_id
else:
reply = 'You took admin rights from %s.' % user.user_id
else:
reply = 'You can not strip yourself of your admin rights.'
except User.NotLoggedIn, e:
reply = str(e)