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


Python settings.IGNORABLE_404_URLS屬性代碼示例

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


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

示例1: _is_ignorable_404

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import IGNORABLE_404_URLS [as 別名]
def _is_ignorable_404(uri):
    """
    Returns True if a 404 at the given URL *shouldn't* notify the site managers.
    """
    if getattr(settings, 'IGNORABLE_404_STARTS', ()):
        import warnings
        warnings.warn('The IGNORABLE_404_STARTS setting has been deprecated '
                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
        for start in settings.IGNORABLE_404_STARTS:
            if uri.startswith(start):
                return True
    if getattr(settings, 'IGNORABLE_404_ENDS', ()):
        import warnings
        warnings.warn('The IGNORABLE_404_ENDS setting has been deprecated '
                      'in favor of IGNORABLE_404_URLS.', DeprecationWarning)
        for end in settings.IGNORABLE_404_ENDS:
            if uri.endswith(end):
                return True
    return any(pattern.search(uri) for pattern in settings.IGNORABLE_404_URLS) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:21,代碼來源:common.py

示例2: is_ignorable_request

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import IGNORABLE_404_URLS [as 別名]
def is_ignorable_request(self, request, uri, domain, referer):
        """
        Return True if the given request *shouldn't* notify the site managers
        according to project settings or in three specific situations:
         - If the referer is empty.
         - If a '?' in referer is identified as a search engine source.
         - If the referer is equal to the current URL, ignoring the scheme
           (assumed to be a poorly implemented bot).
        """
        if not referer:
            return True

        if not self.is_internal_request(domain, referer) and '?' in referer:
            return True

        parsed_referer = urlparse(referer)
        if parsed_referer.netloc in ['', domain] and parsed_referer.path == uri:
            return True

        return any(pattern.search(uri) for pattern in settings.IGNORABLE_404_URLS) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:22,代碼來源:common.py

示例3: is_ignorable_request

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import IGNORABLE_404_URLS [as 別名]
def is_ignorable_request(self, request, uri, domain, referer):
        """
        Returns True if the given request *shouldn't* notify the site managers.
        """
        # '?' in referer is identified as search engine source
        if (not referer or
                (not self.is_internal_request(domain, referer) and '?' in referer)):
            return True
        return any(pattern.search(uri) for pattern in settings.IGNORABLE_404_URLS) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:11,代碼來源:common.py

示例4: is_ignorable_request

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import IGNORABLE_404_URLS [as 別名]
def is_ignorable_request(self, request, uri, domain, referer):
        """
        Return True if the given request *shouldn't* notify the site managers
        according to project settings or in situations outlined by the inline
        comments.
        """
        # The referer is empty.
        if not referer:
            return True

        # APPEND_SLASH is enabled and the referer is equal to the current URL
        # without a trailing slash indicating an internal redirect.
        if settings.APPEND_SLASH and uri.endswith('/') and referer == uri[:-1]:
            return True

        # A '?' in referer is identified as a search engine source.
        if not self.is_internal_request(domain, referer) and '?' in referer:
            return True

        # The referer is equal to the current URL, ignoring the scheme (assumed
        # to be a poorly implemented bot).
        parsed_referer = urlparse(referer)
        if parsed_referer.netloc in ['', domain] and parsed_referer.path == uri:
            return True

        return any(pattern.search(uri) for pattern in settings.IGNORABLE_404_URLS) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:28,代碼來源:common.py


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