当前位置: 首页>>代码示例>>Python>>正文


Python User.get_by_user_id方法代码示例

本文整理汇总了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
开发者ID:miri64,项目名称:spline_social,代码行数:9,代码来源:rpcs.py

示例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,
         }
开发者ID:miri64,项目名称:spline_social,代码行数:10,代码来源:rpcs.py

示例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
         )
开发者ID:miri64,项目名称:spline_social,代码行数:14,代码来源:rpcs.py

示例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)
开发者ID:miri64,项目名称:spline_social,代码行数:16,代码来源:irc.py

示例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)
开发者ID:miri64,项目名称:spline_social,代码行数:23,代码来源:irc.py

示例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)
开发者ID:miri64,项目名称:spline_social,代码行数:24,代码来源:irc.py


注:本文中的db.User.get_by_user_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。