本文整理匯總了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)
示例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)
示例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 "."))