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


Python request.url2pathname方法代碼示例

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


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

示例1: file_path

# 需要導入模塊: from django.utils.six.moves.urllib import request [as 別名]
# 或者: from django.utils.six.moves.urllib.request import url2pathname [as 別名]
def file_path(self, url):
        """
        Returns the relative path to the media file on disk for the given URL.
        """
        relative_url = url[len(self.base_url[2]):]
        return url2pathname(relative_url) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:8,代碼來源:handlers.py

示例2: file_path

# 需要導入模塊: from django.utils.six.moves.urllib import request [as 別名]
# 或者: from django.utils.six.moves.urllib.request import url2pathname [as 別名]
def file_path(self, url):
        """
        Returns the relative path to the file on disk for the given URL.
        """
        relative_url = url[len(self.base_url[2]):]
        return url2pathname(relative_url) 
開發者ID:ComputerSocietyUNB,項目名稱:CodingDojo,代碼行數:8,代碼來源:testcases.py

示例3: get_filename

# 需要導入模塊: from django.utils.six.moves.urllib import request [as 別名]
# 或者: from django.utils.six.moves.urllib.request import url2pathname [as 別名]
def get_filename(self, basename):
        """
        Returns full path to a file, for example:

        get_filename('css/one.css') -> '/full/path/to/static/css/one.css'
        """
        filename = None
        # First try finding the file using the storage class.
        # This is skipped in DEBUG mode as files might be outdated in
        # compressor's final destination (COMPRESS_ROOT) during development
        if not settings.DEBUG:
            try:
                # call path first so remote storages don't make it to exists,
                # which would cause network I/O
                filename = self.storage.path(basename)
                if not self.storage.exists(basename):
                    filename = None
            except NotImplementedError:
                # remote storages don't implement path, access the file locally
                if compressor_file_storage.exists(basename):
                    filename = compressor_file_storage.path(basename)
        # secondly try to find it with staticfiles
        if not filename and self.finders:
            filename = self.finders.find(url2pathname(basename))
        if filename:
            return filename
        # or just raise an exception as the last resort
        raise UncompressableFileError(
            "'%s' could not be found in the COMPRESS_ROOT '%s'%s" %
            (basename, settings.COMPRESS_ROOT,
             self.finders and " or with staticfiles." or ".")) 
開發者ID:openstack,項目名稱:deb-python-django-compressor,代碼行數:33,代碼來源:base.py


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