示例#1
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     check_settings(base_url)
     super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
示例#2
0
 def get_base_url(self):
     if not settings.STATIC_URL:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATIC_URL setting. Set it to "
             "URL that handles the files served from STATIC_ROOT.")
     if settings.DEBUG:
         utils.check_settings()
     return settings.STATIC_URL
示例#3
0
 def __init__(self, location=None, base_url=None, static_root='', static_url=None, *args, **kwargs):
     if location is None:
         location = static_root
     if base_url is None:
         base_url = static_url
     check_settings(base_url)
     super(StaticFilesStorage, self).__init__(location, base_url,
                                              *args, **kwargs)
示例#4
0
 def __init__(self, application, media_dir=None):
     self.application = application
     if media_dir:
         self.media_dir = media_dir
     else:
         self.media_dir = self.get_media_dir()
     self.media_url = urlparse(self.get_media_url())
     if settings.DEBUG:
         utils.check_settings()
     super(StaticFilesHandler, self).__init__()
示例#5
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     if not location:
         raise ImproperlyConfigured("You're using the staticfiles app "
                                    "without having set the STATIC_ROOT "
                                    "setting to a filesystem path.")
     check_settings(base_url)
     super(StaticFilesStorage, self).__init__(location, base_url,
                                              *args, **kwargs)
示例#6
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     check_settings(base_url)
     super().__init__(location, base_url, *args, **kwargs)
     # FileSystemStorage fallbacks to MEDIA_ROOT when location
     # is empty, so we restore the empty value.
     if not location:
         self.base_location = None
         self.location = None
示例#7
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     check_settings(base_url)
     super(StaticFilesStorage, self).__init__(location, base_url,
                                              *args, **kwargs)
     # FileSystemStorage fallbacks to MEDIA_ROOT when location
     # is empty, so we restore the empty value.
     if not location:
         self.base_location = None
         self.location = None
示例#8
0
    def base_url(self):
        if self._base_url is not None and not self._base_url.endswith('/'):
            self._base_url += '/'
        _url = self._value_or_setting(self._base_url, settings.STATIC_URL)

        _url = os.path.join(_url,
                            utils.parse_tenant_config_path(self.relative_static_root))
        if not _url.endswith("/"):
            _url += "/"

        check_settings(_url)

        return _url
示例#9
0
文件: storage.py 项目: lapbay/milan
	def __init__(self, location=None, base_url=None, *args, **kwargs):
		if location is None:
			location = settings.STATIC_ROOT
		if base_url is None:
			base_url = settings.STATIC_URL
		if not location:
			raise ImproperlyConfigured("You're using the staticfiles app "
				"without having set the STATIC_ROOT setting.")
		# check for None since we might use a root URL (``/``)
		if base_url is None:
			raise ImproperlyConfigured("You're using the staticfiles app "
				"without having set the STATIC_URL setting.")
		utils.check_settings()
		super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
示例#10
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     if not location:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATIC_ROOT setting.")
     # check for None since we might use a root URL (``/``)
     if base_url is None:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATIC_URL setting.")
     utils.check_settings()
     super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
示例#11
0
文件: storage.py 项目: GoSteven/Diary
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATICFILES_ROOT
     if base_url is None:
         base_url = settings.STATICFILES_URL
     if not location:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATICFILES_ROOT setting. Set it to "
             "the absolute path of the directory that holds static media.")
     if not base_url:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATICFILES_URL setting. Set it to "
             "URL that handles the files served from STATICFILES_ROOT.")
     if settings.DEBUG:
         utils.check_settings()
     super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
示例#12
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     if not location:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATIC_ROOT setting. Set it to "
             "the absolute path of the directory that holds static files.")
     # check for None since we might use a root URL (``/``)
     if base_url is None:
         raise ImproperlyConfigured("You're using the staticfiles app "
             "without having set the STATIC_URL setting. Set it to "
             "URL that handles the files served from STATIC_ROOT.")
     utils.check_settings()
     super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
示例#13
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATICFILES_ROOT
     if base_url is None:
         base_url = settings.STATICFILES_URL
     if not location:
         raise ImproperlyConfigured(
             "You're using the staticfiles app "
             "without having set the STATICFILES_ROOT setting. Set it to "
             "the absolute path of the directory that holds static media.")
     if not base_url:
         raise ImproperlyConfigured(
             "You're using the staticfiles app "
             "without having set the STATICFILES_URL setting. Set it to "
             "URL that handles the files served from STATICFILES_ROOT.")
     if settings.DEBUG:
         utils.check_settings()
     super(StaticFilesStorage, self).__init__(location, base_url, *args,
                                              **kwargs)
示例#14
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if location is None:
         location = settings.STATIC_ROOT
     if base_url is None:
         base_url = settings.STATIC_URL
     if not location:
         raise ImproperlyConfigured(
             "You're using the staticfiles app "
             "without having set the STATIC_ROOT setting. Set it to "
             "the absolute path of the directory that holds static files.")
     # check for None since we might use a root URL (``/``)
     if base_url is None:
         raise ImproperlyConfigured(
             "You're using the staticfiles app "
             "without having set the STATIC_URL setting. Set it to "
             "URL that handles the files served from STATIC_ROOT.")
     utils.check_settings()
     super(StaticFilesStorage, self).__init__(location, base_url, *args,
                                              **kwargs)
示例#15
0
    def __init__(self, location=None, base_url=None, *args, **kwargs):

        try:
            relative_static_root = settings.MULTITENANT_RELATIVE_STATIC_ROOT
        except AttributeError:
            # MULTITENANT_RELATIVE_STATIC_ROOT is an optional setting, use the default value if none provided
            relative_static_root = ""

        relative_static_root = utils.parse_tenant_config_path(
            relative_static_root)

        if location is None:
            location = os.path.join(settings.STATIC_ROOT, relative_static_root)
        if base_url is None:
            base_url = os.path.join(settings.STATIC_URL, relative_static_root)
            if not base_url.endswith("/"):
                base_url += "/"

        check_settings(base_url)

        super(TenantStaticFilesStorage, self).__init__(location, base_url,
                                                       *args, **kwargs)
示例#16
0
from __future__ import unicode_literals
示例#17
0
 def test_media_url_in_static_url(self):
     msg = "runserver can't serve media if MEDIA_URL is within STATIC_URL."
     with self.assertRaisesMessage(ImproperlyConfigured, msg):
         check_settings()
     with self.settings(DEBUG=False):  # Check disabled if DEBUG=False.
         check_settings()
示例#18
0
from django.conf import settings
示例#19
0
 def get_base_url(self):
     utils.check_settings()
     # TODO: Don't hardcode this value
     return '/static/'
示例#20
0
 def get_base_url(self):
     utils.check_settings()
     return settings.STATIC_URL
示例#21
0
 def __init__(self, location=None, base_url=None, *args, **kwargs):
     if base_url is None:
         base_url = settings.STATIC_URL
     check_settings(base_url)
     self.base_url = base_url
     super(StaticFilesStorage, self).__init__(*args, **kwargs)