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


Python FlaskClient.__mro__方法代碼示例

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


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

示例1: _find_error_handler

# 需要導入模塊: from flask.testing import FlaskClient [as 別名]
# 或者: from flask.testing.FlaskClient import __mro__ [as 別名]
def _find_error_handler(self, e):
        """Finds a registered error handler for the request’s blueprint.
        Otherwise falls back to the app, returns None if not a suitable
        handler is found.
        """
        exc_class, code = self._get_exc_class_and_code(type(e))

        def find_handler(handler_map):
            if not handler_map:
                return
            queue = deque(exc_class.__mro__)
            # Protect from geniuses who might create circular references in
            # __mro__
            done = set()

            while queue:
                cls = queue.popleft()
                if cls in done:
                    continue
                done.add(cls)
                handler = handler_map.get(cls)
                if handler is not None:
                    # cache for next time exc_class is raised
                    handler_map[exc_class] = handler
                    return handler

                queue.extend(cls.__mro__)

        # try blueprint handlers
        handler = find_handler(self.error_handler_spec
                               .get(request.blueprint, {})
                               .get(code))
        if handler is not None:
            return handler

        # fall back to app handlers
        return find_handler(self.error_handler_spec[None].get(code)) 
開發者ID:Desgard,項目名稱:swjtu-pyscraper,代碼行數:39,代碼來源:app.py


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