當前位置: 首頁>>代碼示例>>Python>>正文


Python Identity.find_first方法代碼示例

本文整理匯總了Python中indico.modules.auth.Identity.find_first方法的典型用法代碼示例。如果您正苦於以下問題:Python Identity.find_first方法的具體用法?Python Identity.find_first怎麽用?Python Identity.find_first使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在indico.modules.auth.Identity的用法示例。


在下文中一共展示了Identity.find_first方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _original_user

# 需要導入模塊: from indico.modules.auth import Identity [as 別名]
# 或者: from indico.modules.auth.Identity import find_first [as 別名]
 def _original_user(self):
     # A proper user, with an id that can be mapped directly to sqlalchemy
     if isinstance(self.id, int) or self.id.isdigit():
         return User.get(int(self.id))
     # A user who had no real indico account but an ldap identifier/email.
     # In this case we try to find his real user and replace the ID of this object
     # with that user's ID.
     data = self.id.split(':')
     # TODO: Once everything is in SQLAlchemy this whole thing needs to go away!
     user = None
     if data[0] == 'LDAP':
         identifier = data[1]
         email = data[2]
         # You better have only one ldap provider or at least different identifiers ;)
         identity = Identity.find_first(Identity.provider != 'indico', Identity.identifier == identifier)
         if identity:
             user = identity.user
     elif data[0] == 'Nice':
         email = data[1]
     else:
         return None
     if not user:
         user = User.find_first(User.all_emails.contains(email))
     if user:
         self._old_id = self.id
         self.id = str(user.id)
         logger.info("Updated legacy user id (%s => %s)", self._old_id, self.id)
     return user
開發者ID:fph,項目名稱:indico,代碼行數:30,代碼來源:legacy.py


注:本文中的indico.modules.auth.Identity.find_first方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。