diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-11-17 15:36:26 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-11-17 15:36:26 +0000 |
| commit | 33d8fcde8a317184a627492f008a4eab9333ed88 (patch) | |
| tree | 7c877854327c83aefdfaf00e727d26bd766e519e /django/core/servers/basehttp.py | |
| parent | 9b45f6cd5444423693715cc2a04d91a0de75060b (diff) | |
Fixed #14693, #14709 -- Backwards incompatible change to rectify the confusion around the STATICFILES_URL and STATICFILES_ROOT settings.
* Two new global settings that will be used by -- **but are not limited to** -- the staticfiles app: STATIC_ROOT and STATIC_URL.
* Moving the 'django.contrib.staticfiles.templatetags.staticfiles' template tag to the core ('django.templatetags.static') and renaming it to 'get_static_prefix'.
* Moving the context processor 'django.contrib.staticfiles.context_processors.staticfiles' to the core ('django.core.context_processors.static') and renaming it to 'static'.
* Paths in media definitions will use STATIC_URL as the prefix if the value is not None, and falls back to the previously used MEDIA_URL.
Thanks again to the community for constructive criticism and Carl and Russ for sanity-inducing discussions on IRC.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/servers/basehttp.py')
| -rw-r--r-- | django/core/servers/basehttp.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index 9c92a88b44..9c3e90043b 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -17,8 +17,8 @@ import warnings from django.core.management.color import color_style from django.utils.http import http_date from django.utils._os import safe_join -from django.contrib.staticfiles.handlers import StaticFilesHandler -from django.views import static + +from django.contrib.staticfiles import handlers, views as static __version__ = "0.1" __all__ = ['WSGIServer','WSGIRequestHandler'] @@ -635,19 +635,20 @@ class WSGIRequestHandler(BaseHTTPRequestHandler): sys.stderr.write(msg) -class AdminMediaHandler(StaticFilesHandler): +class AdminMediaHandler(handlers.StaticFilesHandler): """ WSGI middleware that intercepts calls to the admin media directory, as defined by the ADMIN_MEDIA_PREFIX setting, and serves those images. Use this ONLY LOCALLY, for development! This hasn't been tested for security and is not super efficient. - """ - def get_media_dir(self): + This is pending for deprecation since 1.3. + """ + def get_base_dir(self): import django return os.path.join(django.__path__[0], 'contrib', 'admin', 'media') - def get_media_url(self): + def get_base_url(self): from django.conf import settings return settings.ADMIN_MEDIA_PREFIX @@ -655,14 +656,13 @@ class AdminMediaHandler(StaticFilesHandler): """ Returns the path to the media file on disk for the given URL. - The passed URL is assumed to begin with ``media_url``. If the - resultant file path is outside the media directory, then a ValueError + The passed URL is assumed to begin with ``self.base_url``. If the + resulting file path is outside the media directory, then a ValueError is raised. """ - # Remove ``media_url``. - relative_url = url[len(self.media_url[2]):] + relative_url = url[len(self.base_url[2]):] relative_path = urllib.url2pathname(relative_url) - return safe_join(self.media_dir, relative_path) + return safe_join(self.base_dir, relative_path) def serve(self, request): document_root, path = os.path.split(self.file_path(request.path)) @@ -673,10 +673,10 @@ class AdminMediaHandler(StaticFilesHandler): """ Checks if the path should be handled. Ignores the path if: - * the host is provided as part of the media_url - * the request's path isn't under the media path + * the host is provided as part of the base_url + * the request's path isn't under the base path """ - return path.startswith(self.media_url[2]) and not self.media_url[1] + return path.startswith(self.base_url[2]) and not self.base_url[1] def run(addr, port, wsgi_handler): |
