Ticket #18035: 18035-2.diff
File 18035-2.diff, 24.7 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/static/admin/js/SelectFilter2.js
diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index 0accd08..24d88f7 100644
a b function findForm(node) { 13 13 } 14 14 15 15 window.SelectFilter = { 16 init: function(field_id, field_name, is_stacked, admin_ media_prefix) {16 init: function(field_id, field_name, is_stacked, admin_static_prefix) { 17 17 if (field_id.match(/__prefix__/)){ 18 18 // Don't intialize on empty forms. 19 19 return; … … window.SelectFilter = { 43 43 var selector_available = quickElement('div', selector_div, ''); 44 44 selector_available.className = 'selector-available'; 45 45 var title_available = quickElement('h2', selector_available, interpolate(gettext('Available %s') + ' ', [field_name])); 46 quickElement('img', title_available, '', 'src', admin_ media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of available %s. You may choose some by selecting them in the box below and then clicking the "Choose" arrow between the two boxes.'), [field_name]));46 quickElement('img', title_available, '', 'src', admin_static_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of available %s. You may choose some by selecting them in the box below and then clicking the "Choose" arrow between the two boxes.'), [field_name])); 47 47 48 48 var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter'); 49 49 filter_p.className = 'selector-filter'; 50 50 51 51 var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + "_input"); 52 52 53 var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_ media_prefix + 'img/selector-search.gif', 'class', 'help-tooltip', 'alt', '', 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name]));53 var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_static_prefix + 'img/selector-search.gif', 'class', 'help-tooltip', 'alt', '', 'title', interpolate(gettext("Type into this box to filter down the list of available %s."), [field_name])); 54 54 55 55 filter_p.appendChild(document.createTextNode(' ')); 56 56 … … window.SelectFilter = { 73 73 var selector_chosen = quickElement('div', selector_div, ''); 74 74 selector_chosen.className = 'selector-chosen'; 75 75 var title_chosen = quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s') + ' ', [field_name])); 76 quickElement('img', title_chosen, '', 'src', admin_ media_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of chosen %s. You may remove some by selecting them in the box below and then clicking the "Remove" arrow between the two boxes.'), [field_name]));76 quickElement('img', title_chosen, '', 'src', admin_static_prefix + 'img/icon-unknown.gif', 'width', '10', 'height', '10', 'class', 'help help-tooltip', 'title', interpolate(gettext('This is the list of chosen %s. You may remove some by selecting them in the box below and then clicking the "Remove" arrow between the two boxes.'), [field_name])); 77 77 78 78 var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name')); 79 79 to_box.className = 'filtered'; -
django/contrib/gis/admin/widgets.py
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index 6dbbc60..aaffae8 100644
a b from django.contrib.gis.geos import GEOSGeometry, GEOSException 8 8 9 9 # Creating a template context that contains Django settings 10 10 # values needed by admin map templates. 11 geo_context = Context({'ADMIN_MEDIA_PREFIX' : static('admin/'), 12 'LANGUAGE_BIDI' : translation.get_language_bidi()}) 11 geo_context = Context({'LANGUAGE_BIDI' : translation.get_language_bidi()}) 13 12 14 13 class OpenLayersWidget(Textarea): 15 14 """ -
django/contrib/staticfiles/management/commands/runserver.py
diff --git a/django/contrib/staticfiles/management/commands/runserver.py b/django/contrib/staticfiles/management/commands/runserver.py index 403df88..0f9e39f 100644
a b 1 1 from optparse import make_option 2 2 3 3 from django.conf import settings 4 from django.core.management.commands.runserver import BaseRunserverCommand4 from django.core.management.commands.runserver import Command as RunserverCommand 5 5 6 6 from django.contrib.staticfiles.handlers import StaticFilesHandler 7 7 8 class Command( BaseRunserverCommand):9 option_list = BaseRunserverCommand.option_list + (8 class Command(RunserverCommand): 9 option_list = RunserverCommand.option_list + ( 10 10 make_option('--nostatic', action="store_false", dest='use_static_handler', default=True, 11 11 help='Tells Django to NOT automatically serve static files at STATIC_URL.'), 12 12 make_option('--insecure', action="store_true", dest='insecure_serving', default=False, -
django/core/management/commands/runserver.py
diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py index e93af96..3007d0f 100644
a b import sys 5 5 import socket 6 6 7 7 from django.core.management.base import BaseCommand, CommandError 8 from django.core.servers.basehttp import AdminMediaHandler,run, WSGIServerException, get_internal_wsgi_application8 from django.core.servers.basehttp import run, WSGIServerException, get_internal_wsgi_application 9 9 from django.utils import autoreload 10 10 11 11 naiveip_re = re.compile(r"""^(?: … … naiveip_re = re.compile(r"""^(?: 17 17 DEFAULT_PORT = "8000" 18 18 19 19 20 class BaseRunserverCommand(BaseCommand):20 class Command(BaseCommand): 21 21 option_list = BaseCommand.option_list + ( 22 22 make_option('--ipv6', '-6', action='store_true', dest='use_ipv6', default=False, 23 23 help='Tells Django to use a IPv6 address.'), … … class BaseRunserverCommand(BaseCommand): 128 128 self.stdout.write("%s\n" % shutdown_message) 129 129 sys.exit(0) 130 130 131 class Command(BaseRunserverCommand):132 option_list = BaseRunserverCommand.option_list + (133 make_option('--adminmedia', dest='admin_media_path', default='',134 help='Specifies the directory from which to serve admin media.'),135 )136 131 137 def get_handler(self, *args, **options): 138 """ 139 Serves admin media like old-school (deprecation pending). 140 """ 141 handler = super(Command, self).get_handler(*args, **options) 142 return AdminMediaHandler(handler, options.get('admin_media_path')) 132 # Kept for backward compatibility 133 BaseRunserverCommand = Command -
django/core/servers/basehttp.py
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index 8d4ceab..d538ce7 100644
a b from django.core.exceptions import ImproperlyConfigured 22 22 from django.core.management.color import color_style 23 23 from django.core.wsgi import get_wsgi_application 24 24 from django.utils.importlib import import_module 25 from django.utils._os import safe_join26 from django.views import static27 28 from django.contrib.staticfiles import handlers29 25 30 26 __all__ = ['WSGIServer', 'WSGIRequestHandler'] 31 27 … … class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): 131 127 132 128 def __init__(self, *args, **kwargs): 133 129 from django.conf import settings 134 self.admin_ media_prefix = urlparse.urljoin(settings.STATIC_URL, 'admin/')130 self.admin_static_prefix = urlparse.urljoin(settings.STATIC_URL, 'admin/') 135 131 # We set self.path to avoid crashes in log_message() on unsupported 136 132 # requests (like "OPTIONS"). 137 133 self.path = '' … … class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): 173 169 174 170 def log_message(self, format, *args): 175 171 # Don't bother logging requests for admin images or the favicon. 176 if (self.path.startswith(self.admin_ media_prefix)172 if (self.path.startswith(self.admin_static_prefix) 177 173 or self.path == '/favicon.ico'): 178 174 return 179 175 … … class WSGIRequestHandler(simple_server.WSGIRequestHandler, object): 200 196 sys.stderr.write(msg) 201 197 202 198 203 class AdminMediaHandler(handlers.StaticFilesHandler):204 """205 WSGI middleware that intercepts calls to the admin media directory, as206 defined by the STATIC_URL setting, and serves those images.207 Use this ONLY LOCALLY, for development! This hasn't been tested for208 security and is not super efficient.209 210 This is pending for deprecation since 1.3.211 """212 def get_base_dir(self):213 return os.path.join(django.__path__[0], 'contrib', 'admin', 'static', 'admin')214 215 def get_base_url(self):216 from django.conf import settings217 return urlparse.urljoin(settings.STATIC_URL, 'admin/')218 219 def file_path(self, url):220 """221 Returns the path to the media file on disk for the given URL.222 223 The passed URL is assumed to begin with ``self.base_url``. If the224 resulting file path is outside the media directory, then a ValueError225 is raised.226 """227 relative_url = url[len(self.base_url[2]):]228 relative_path = urllib.url2pathname(relative_url)229 return safe_join(self.base_dir, relative_path)230 231 def serve(self, request):232 document_root, path = os.path.split(self.file_path(request.path))233 return static.serve(request, path, document_root=document_root)234 235 def _should_handle(self, path):236 """237 Checks if the path should be handled. Ignores the path if:238 239 * the host is provided as part of the base_url240 * the request's path isn't under the base path241 """242 return path.startswith(self.base_url[2]) and not self.base_url[1]243 244 245 199 def run(addr, port, wsgi_handler, ipv6=False, threading=False): 246 200 server_address = (addr, port) 247 201 if threading: -
docs/howto/deployment/wsgi/gunicorn.txt
diff --git a/docs/howto/deployment/wsgi/gunicorn.txt b/docs/howto/deployment/wsgi/gunicorn.txt index ce9e54d..13d4043 100644
a b This provides a few Django-specific niceties: 58 58 * validates installed models 59 59 60 60 * allows an ``--adminmedia`` option for passing in the location of the 61 admin media files , mimicing the behavior of runserver.61 admin media files. 62 62 63 63 See Gunicorn's `deployment documentation`_ for additional tips on starting and 64 64 maintaining the Gunicorn server. -
docs/man/django-admin.1
diff --git a/docs/man/django-admin.1 b/docs/man/django-admin.1 index 1f693b8..730f3a5 100644
a b Runs this project as a FastCGI application. Requires flup. Use 75 75 .B runfcgi help 76 76 for help on the KEY=val pairs. 77 77 .TP 78 .BI "runserver [" "\-\-noreload" "] [" "\-\-nothreading" "] [" "\-\-nostatic" "] [" "\-\-insecure" "] [" "\-\-ipv6" "] [" " \-\-adminmedia=ADMIN_MEDIA_PATH" "] [" "port|ipaddr:port" "]"78 .BI "runserver [" "\-\-noreload" "] [" "\-\-nothreading" "] [" "\-\-nostatic" "] [" "\-\-insecure" "] [" "\-\-ipv6" "] [" "port|ipaddr:port" "]" 79 79 Starts a lightweight Web server for development. 80 80 .TP 81 81 .BI "shell [" "\-\-plain" "]" … … Enables IPv6 addresses. 178 178 .I \-\-verbosity=VERBOSITY 179 179 Verbosity level: 0=minimal output, 1=normal output, 2=all output. 180 180 .TP 181 .I \-\-adminmedia=ADMIN_MEDIA_PATH182 Specifies the directory from which to serve admin media when using the development server.183 .TP184 181 .I \-\-traceback 185 182 By default, django-admin.py will show a simple error message whenever an 186 183 error occurs. If you specify this option, django-admin.py will -
docs/ref/django-admin.txt
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 5ea7280..93844a6 100644
a b You can provide an IPv6 address surrounded by brackets 674 674 675 675 A hostname containing ASCII-only characters can also be used. 676 676 677 .. django-admin-option:: --adminmedia678 679 Use the ``--adminmedia`` option to tell Django where to find the various CSS680 and JavaScript files for the Django admin interface. Normally, the development681 server serves these files out of the Django source tree magically, but you'd682 want to use this if you made any changes to those files for your own site.683 684 Example usage::685 686 django-admin.py runserver --adminmedia=/tmp/new-admin-style/687 688 677 .. versionchanged:: 1.3 689 678 690 679 If the :doc:`staticfiles</ref/contrib/staticfiles>` contrib app is enabled 691 680 (default in new projects) the :djadmin:`runserver` command will be overriden 692 with an own :djadmin:`runserver<staticfiles-runserver>` command which doesn't 693 have the :djadminopt:`--adminmedia` option due to deprecation. 681 with an own :djadmin:`runserver<staticfiles-runserver>` command. 694 682 695 683 .. django-admin-option:: --noreload 696 684 -
tests/regressiontests/admin_scripts/tests.py
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index dd3b0b4..7fee78a 100644
a b class ManageTestCommand(AdminScriptTestCase): 1105 1105 1106 1106 class ManageRunserver(AdminScriptTestCase): 1107 1107 def setUp(self): 1108 from django.core.management.commands.runserver import BaseRunserverCommand1108 from django.core.management.commands.runserver import Command 1109 1109 1110 1110 def monkey_run(*args, **options): 1111 1111 return 1112 1112 1113 self.cmd = BaseRunserverCommand()1113 self.cmd = Command() 1114 1114 self.cmd.run = monkey_run 1115 1115 1116 1116 def assertServerSettings(self, addr, port, ipv6=None, raw_ipv6=False): -
tests/regressiontests/admin_widgets/tests.py
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py index ab6db4d..c1116ba 100644
a b from . import models 20 20 from .widgetadmin import site as widget_admin_site 21 21 22 22 23 admin_ media_prefix = lambda: {24 'ADMIN_ MEDIA_PREFIX': "%sadmin/" % settings.STATIC_URL,23 admin_static_prefix = lambda: { 24 'ADMIN_STATIC_PREFIX': "%sadmin/" % settings.STATIC_URL, 25 25 } 26 26 27 27 class AdminFormfieldForDBFieldTests(TestCase): … … class FilteredSelectMultipleWidgetTest(DjangoTestCase): 196 196 w = widgets.FilteredSelectMultiple('test', False) 197 197 self.assertHTMLEqual( 198 198 conditional_escape(w.render('test', 'test')), 199 '<select multiple="multiple" name="test" class="selectfilter">\n</select><script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("id_test", "test", 0, "%(ADMIN_ MEDIA_PREFIX)s"); });</script>\n' % admin_media_prefix()199 '<select multiple="multiple" name="test" class="selectfilter">\n</select><script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("id_test", "test", 0, "%(ADMIN_STATIC_PREFIX)s"); });</script>\n' % admin_static_prefix() 200 200 ) 201 201 202 202 def test_stacked_render(self): 203 203 w = widgets.FilteredSelectMultiple('test', True) 204 204 self.assertHTMLEqual( 205 205 conditional_escape(w.render('test', 'test')), 206 '<select multiple="multiple" name="test" class="selectfilterstacked">\n</select><script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("id_test", "test", 1, "%(ADMIN_ MEDIA_PREFIX)s"); });</script>\n' % admin_media_prefix()206 '<select multiple="multiple" name="test" class="selectfilterstacked">\n</select><script type="text/javascript">addEvent(window, "load", function(e) {SelectFilter.init("id_test", "test", 1, "%(ADMIN_STATIC_PREFIX)s"); });</script>\n' % admin_static_prefix() 207 207 ) 208 208 209 209 class AdminDateWidgetTest(DjangoTestCase): … … class ForeignKeyRawIdWidgetTest(DjangoTestCase): 292 292 w = widgets.ForeignKeyRawIdWidget(rel, widget_admin_site) 293 293 self.assertHTMLEqual( 294 294 conditional_escape(w.render('test', band.pk, attrs={})), 295 '<input type="text" name="test" value="%(bandpk)s" class="vForeignKeyRawIdAdminField" /><a href="/widget_admin/admin_widgets/band/?t=id" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_ MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Linkin Park</strong>' % dict(admin_media_prefix(), bandpk=band.pk)295 '<input type="text" name="test" value="%(bandpk)s" class="vForeignKeyRawIdAdminField" /><a href="/widget_admin/admin_widgets/band/?t=id" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_STATIC_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Linkin Park</strong>' % dict(admin_static_prefix(), bandpk=band.pk) 296 296 ) 297 297 298 298 def test_relations_to_non_primary_key(self): … … class ForeignKeyRawIdWidgetTest(DjangoTestCase): 307 307 w = widgets.ForeignKeyRawIdWidget(rel, widget_admin_site) 308 308 self.assertHTMLEqual( 309 309 w.render('test', core.parent_id, attrs={}), 310 '<input type="text" name="test" value="86" class="vForeignKeyRawIdAdminField" /><a href="/widget_admin/admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_ MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Apple</strong>' % admin_media_prefix()310 '<input type="text" name="test" value="86" class="vForeignKeyRawIdAdminField" /><a href="/widget_admin/admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_STATIC_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Apple</strong>' % admin_static_prefix() 311 311 ) 312 312 313 313 def test_fk_related_model_not_in_admin(self): … … class ForeignKeyRawIdWidgetTest(DjangoTestCase): 349 349 ) 350 350 self.assertHTMLEqual( 351 351 w.render('test', child_of_hidden.parent_id, attrs={}), 352 '<input type="text" name="test" value="93" class="vForeignKeyRawIdAdminField" /><a href="/widget_admin/admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_ MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Hidden</strong>' % admin_media_prefix()352 '<input type="text" name="test" value="93" class="vForeignKeyRawIdAdminField" /><a href="/widget_admin/admin_widgets/inventory/?t=barcode" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_STATIC_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Hidden</strong>' % admin_static_prefix() 353 353 ) 354 354 355 355 … … class ManyToManyRawIdWidgetTest(DjangoTestCase): 365 365 w = widgets.ManyToManyRawIdWidget(rel, widget_admin_site) 366 366 self.assertHTMLEqual( 367 367 conditional_escape(w.render('test', [m1.pk, m2.pk], attrs={})), 368 '<input type="text" name="test" value="%(m1pk)s,%(m2pk)s" class="vManyToManyRawIdAdminField" /><a href="/widget_admin/admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="/static/admin/img/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % dict(admin_ media_prefix(), m1pk=m1.pk, m2pk=m2.pk)368 '<input type="text" name="test" value="%(m1pk)s,%(m2pk)s" class="vManyToManyRawIdAdminField" /><a href="/widget_admin/admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="/static/admin/img/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % dict(admin_static_prefix(), m1pk=m1.pk, m2pk=m2.pk) 369 369 ) 370 370 371 371 self.assertHTMLEqual( 372 372 conditional_escape(w.render('test', [m1.pk])), 373 '<input type="text" name="test" value="%(m1pk)s" class="vManyToManyRawIdAdminField" /><a href="/widget_admin/admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_ MEDIA_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % dict(admin_media_prefix(), m1pk=m1.pk)373 '<input type="text" name="test" value="%(m1pk)s" class="vManyToManyRawIdAdminField" /><a href="/widget_admin/admin_widgets/member/" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_STATIC_PREFIX)simg/selector-search.gif" width="16" height="16" alt="Lookup" /></a>' % dict(admin_static_prefix(), m1pk=m1.pk) 374 374 ) 375 375 376 376 self.assertEqual(w._has_changed(None, None), False) … … class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleni 691 691 webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver' 692 692 693 693 class HorizontalVerticalFilterSeleniumIETests(HorizontalVerticalFilterSeleniumFirefoxTests): 694 webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' 695 No newline at end of file 694 webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' -
tests/regressiontests/servers/tests.py
diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py index d237c83..e226be9 100644
a b 2 2 Tests for django.core.servers. 3 3 """ 4 4 import os 5 from urlparse import urljoin6 5 import urllib2 7 6 8 import django9 from django.conf import settings10 7 from django.core.exceptions import ImproperlyConfigured 11 from django.test import TestCase, LiveServerTestCase 12 from django.core.handlers.wsgi import WSGIHandler 13 from django.core.servers.basehttp import AdminMediaHandler, WSGIServerException 8 from django.test import LiveServerTestCase 9 from django.core.servers.basehttp import WSGIServerException 14 10 from django.test.utils import override_settings 15 11 16 12 from .models import Person 17 13 18 class AdminMediaHandlerTests(TestCase):19 20 def setUp(self):21 self.admin_media_url = urljoin(settings.STATIC_URL, 'admin/')22 self.admin_media_file_path = os.path.abspath(23 os.path.join(django.__path__[0], 'contrib', 'admin', 'static', 'admin')24 )25 self.handler = AdminMediaHandler(WSGIHandler())26 27 def test_media_urls(self):28 """29 Tests that URLs that look like absolute file paths after the30 settings.STATIC_URL don't turn into absolute file paths.31 """32 # Cases that should work on all platforms.33 data = (34 ('%scss/base.css' % self.admin_media_url, ('css', 'base.css')),35 )36 # Cases that should raise an exception.37 bad_data = ()38 39 # Add platform-specific cases.40 if os.sep == '/':41 data += (42 # URL, tuple of relative path parts.43 ('%s\\css/base.css' % self.admin_media_url, ('\\css', 'base.css')),44 )45 bad_data += (46 '%s/css/base.css' % self.admin_media_url,47 '%s///css/base.css' % self.admin_media_url,48 '%s../css/base.css' % self.admin_media_url,49 )50 elif os.sep == '\\':51 bad_data += (52 '%sC:\css/base.css' % self.admin_media_url,53 '%s/\\css/base.css' % self.admin_media_url,54 '%s\\css/base.css' % self.admin_media_url,55 '%s\\\\css/base.css' % self.admin_media_url56 )57 for url, path_tuple in data:58 try:59 output = self.handler.file_path(url)60 except ValueError:61 self.fail("Got a ValueError exception, but wasn't expecting"62 " one. URL was: %s" % url)63 rel_path = os.path.join(*path_tuple)64 desired = os.path.join(self.admin_media_file_path, rel_path)65 self.assertEqual(66 os.path.normcase(output), os.path.normcase(desired),67 "Got: %s, Expected: %s, URL was: %s" % (output, desired, url))68 for url in bad_data:69 try:70 output = self.handler.file_path(url)71 except ValueError:72 continue73 self.fail('URL: %s should have caused a ValueError exception.'74 % url)75 76 14 77 15 TEST_ROOT = os.path.dirname(__file__) 78 16 TEST_SETTINGS = {