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


Python UserModel.fill_data方法代碼示例

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


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

示例1: propagate_data

# 需要導入模塊: from kallithea.model.user import UserModel [as 別名]
# 或者: from kallithea.model.user.UserModel import fill_data [as 別名]
    def propagate_data(self):
        user_model = UserModel()
        self.anonymous_user = User.get_default_user(cache=True)
        is_user_loaded = False

        # lookup by userid
        if self.user_id is not None and self.user_id != self.anonymous_user.user_id:
            log.debug('Auth User lookup by USER ID %s' % self.user_id)
            is_user_loaded = user_model.fill_data(self, user_id=self.user_id)

        # try go get user by api key
        elif self._api_key and self._api_key != self.anonymous_user.api_key:
            log.debug('Auth User lookup by API KEY %s' % self._api_key)
            is_user_loaded = user_model.fill_data(self, api_key=self._api_key)

        # lookup by username
        elif self.username:
            log.debug('Auth User lookup by USER NAME %s' % self.username)
            is_user_loaded = user_model.fill_data(self, username=self.username)
        else:
            log.debug('No data in %s that could been used to log in' % self)

        if not is_user_loaded:
            # if we cannot authenticate user try anonymous
            if self.anonymous_user.active:
                user_model.fill_data(self, user_id=self.anonymous_user.user_id)
                # then we set this user is logged in
                self.is_authenticated = True
            else:
                self.user_id = None
                self.username = None
                self.is_authenticated = False

        if not self.username:
            self.username = 'None'

        log.debug('Auth User is now %s' % self)
開發者ID:msabramo,項目名稱:kallithea,代碼行數:39,代碼來源:auth.py


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