当前位置: 首页>>代码示例>>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;未经允许,请勿转载。