Ticket #14389: t14389-rc1.diff
File t14389-rc1.diff, 32.4 KB (added by , 14 years ago) |
---|
-
django/template/defaulttags.py
diff -r 9aed8047e568 django/template/defaulttags.py
a b 290 290 return False 291 291 292 292 class SsiNode(Node): 293 def __init__(self, filepath, parsed): 294 self.filepath, self.parsed = filepath, parsed 293 def __init__(self, filepath, parsed, legacy_filepath=True): 294 self.filepath = filepath 295 self.parsed = parsed 296 self.legacy_filepath = legacy_filepath 295 297 296 298 def render(self, context): 297 if not include_is_allowed(self.filepath): 299 filepath = self.filepath 300 if not self.legacy_filepath: 301 filepath = filepath.resolve(context) 302 303 if not include_is_allowed(filepath): 298 304 if settings.DEBUG: 299 305 return "[Didn't have permission to include file]" 300 306 else: 301 307 return '' # Fail silently for invalid includes. 302 308 try: 303 fp = open( self.filepath, 'r')309 fp = open(filepath, 'r') 304 310 output = fp.read() 305 311 fp.close() 306 312 except IOError: 307 313 output = '' 308 314 if self.parsed: 309 315 try: 310 t = Template(output, name= self.filepath)316 t = Template(output, name=filepath) 311 317 return t.render(context) 312 318 except TemplateSyntaxError, e: 313 319 if settings.DEBUG: … … 356 362 return self.mapping.get(self.tagtype, '') 357 363 358 364 class URLNode(Node): 359 def __init__(self, view_name, args, kwargs, asvar ):365 def __init__(self, view_name, args, kwargs, asvar, legacy_view_name=True): 360 366 self.view_name = view_name 367 self.legacy_view_name = legacy_view_name 361 368 self.args = args 362 369 self.kwargs = kwargs 363 370 self.asvar = asvar … … 365 372 def render(self, context): 366 373 from django.core.urlresolvers import reverse, NoReverseMatch 367 374 args = [arg.resolve(context) for arg in self.args] 368 kwargs = dict([(smart_str(k, 'ascii'), v.resolve(context))375 kwargs = dict([(smart_str(k, 'ascii'), v.resolve(context)) 369 376 for k, v in self.kwargs.items()]) 370 377 378 view_name = self.view_name 379 if not self.legacy_view_name: 380 view_name = view_name.resolve(context) 381 371 382 # Try to look up the URL twice: once given the view name, and again 372 383 # relative to what we guess is the "main" app. If they both fail, 373 384 # re-raise the NoReverseMatch unless we're using the 374 385 # {% url ... as var %} construct in which cause return nothing. 375 386 url = '' 376 387 try: 377 url = reverse( self.view_name, args=args, kwargs=kwargs, current_app=context.current_app)388 url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app) 378 389 except NoReverseMatch, e: 379 390 if settings.SETTINGS_MODULE: 380 391 project_name = settings.SETTINGS_MODULE.split('.')[0] 381 392 try: 382 url = reverse(project_name + '.' + self.view_name, 383 args=args, kwargs=kwargs, current_app=context.current_app) 393 url = reverse(project_name + '.' + view_name, 394 args=args, kwargs=kwargs, 395 current_app=context.current_app) 384 396 except NoReverseMatch: 385 397 if self.asvar is None: 386 398 # Re-raise the original exception, not the one with … … 922 934 923 935 {% ssi /home/html/ljworld.com/includes/right_generic.html parsed %} 924 936 """ 937 938 import warnings 939 warnings.warn('The syntax for the ssi template tag is changing. Load the future_ssi tag library to start using the new behavior.', 940 category=PendingDeprecationWarning) 941 925 942 bits = token.contents.split() 926 943 parsed = False 927 944 if len(bits) not in (2, 3): … … 933 950 else: 934 951 raise TemplateSyntaxError("Second (optional) argument to %s tag" 935 952 " must be 'parsed'" % bits[0]) 936 return SsiNode(bits[1], parsed )953 return SsiNode(bits[1], parsed, legacy_filepath=True) 937 954 ssi = register.tag(ssi) 938 955 939 956 #@register.tag … … 1140 1157 1141 1158 The URL will look like ``/clients/client/123/``. 1142 1159 """ 1160 1161 import warnings 1162 warnings.warn('The syntax for the url template tag is changing. Load the future_url tag library to start using the new behavior.', 1163 category=PendingDeprecationWarning) 1164 1143 1165 bits = token.split_contents() 1144 1166 if len(bits) < 2: 1145 1167 raise TemplateSyntaxError("'%s' takes at least one argument" … … 1196 1218 else: 1197 1219 args.append(parser.compile_filter(value)) 1198 1220 1199 return URLNode(viewname, args, kwargs, asvar )1221 return URLNode(viewname, args, kwargs, asvar, legacy_view_name=True) 1200 1222 url = register.tag(url) 1201 1223 1202 1224 #@register.tag -
new file django/templatetags/future_ssi.py
diff -r 9aed8047e568 django/templatetags/future_ssi.py
- + 1 from django.conf import settings 2 from django.template import Library, Node, Template, TemplateSyntaxError 3 from django.template.defaulttags import include_is_allowed, SsiNode 4 5 6 register = Library() 7 8 @register.tag 9 def ssi(parser, token): 10 """ 11 Outputs the contents of a given file into the page. 12 13 Like a simple "include" tag, the ``ssi`` tag includes the contents 14 of another file -- which must be specified using an absolute path -- 15 in the current page:: 16 17 {% ssi "/home/html/ljworld.com/includes/right_generic.html" %} 18 19 If the optional "parsed" parameter is given, the contents of the included 20 file are evaluated as template code, with the current context:: 21 22 {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %} 23 """ 24 bits = token.contents.split() 25 parsed = False 26 if len(bits) not in (2, 3): 27 raise TemplateSyntaxError("'ssi' tag takes one argument: the path to" 28 " the file to be included") 29 if len(bits) == 3: 30 if bits[2] == 'parsed': 31 parsed = True 32 else: 33 raise TemplateSyntaxError("Second (optional) argument to %s tag" 34 " must be 'parsed'" % bits[0]) 35 filepath = parser.compile_filter(bits[1]) 36 return SsiNode(filepath, parsed, legacy_filepath=False) 37 -
new file django/templatetags/future_url.py
diff -r 9aed8047e568 django/templatetags/future_url.py
- + 1 from django.conf import settings 2 from django.template import Library, Node, TemplateSyntaxError 3 from django.template.defaulttags import kwarg_re, URLNode 4 from django.utils.encoding import smart_str 5 6 7 register = Library() 8 9 @register.tag 10 def url(parser, token): 11 """ 12 Returns an absolute URL matching given view with its parameters. 13 14 This is a way to define links that aren't tied to a particular URL 15 configuration:: 16 17 {% url "path.to.some_view" arg1 arg2 %} 18 19 or 20 21 {% url "path.to.some_view" name1=value1 name2=value2 %} 22 23 The first argument is a path to a view. It can be an absolute python path 24 or just ``app_name.view_name`` without the project name if the view is 25 located inside the project. Other arguments are comma-separated values 26 that will be filled in place of positional and keyword arguments in the 27 URL. All arguments for the URL should be present. 28 29 For example if you have a view ``app_name.client`` taking client's id and 30 the corresponding line in a URLconf looks like this:: 31 32 ('^client/(\d+)/$', 'app_name.client') 33 34 and this app's URLconf is included into the project's URLconf under some 35 path:: 36 37 ('^clients/', include('project_name.app_name.urls')) 38 39 then in a template you can create a link for a certain client like this:: 40 41 {% url "app_name.client" client.id %} 42 43 The URL will look like ``/clients/client/123/``. 44 """ 45 bits = token.split_contents() 46 if len(bits) < 2: 47 raise TemplateSyntaxError("'%s' takes at least one argument" 48 " (path to a view)" % bits[0]) 49 viewname = parser.compile_filter(bits[1]) 50 args = [] 51 kwargs = {} 52 asvar = None 53 bits = bits[2:] 54 if len(bits) >= 2 and bits[-2] == 'as': 55 asvar = bits[-1] 56 bits = bits[:-2] 57 58 if len(bits): 59 for bit in bits: 60 match = kwarg_re.match(bit) 61 if not match: 62 raise TemplateSyntaxError("Malformed arguments to url tag") 63 name, value = match.groups() 64 if name: 65 kwargs[name] = parser.compile_filter(value) 66 else: 67 args.append(parser.compile_filter(value)) 68 69 return URLNode(viewname, args, kwargs, asvar, legacy_view_name=False) 70 -
docs/internals/deprecation.txt
diff -r 9aed8047e568 docs/internals/deprecation.txt
a b 131 131 been deprecated in favor of the 132 132 :class:`~django.contrib.staticfiles.handlers.StaticFilesHandler`. 133 133 134 * The :ttag:`url` and :ttag:`ssi` template tags will be modified so that 135 the first argument to each tag is a template variable, not an implied 136 string. The new-style behavior is provided with the ``future_url`` and 137 ``future_ssi`` template tag libraries. 138 134 139 * 2.0 135 140 * ``django.views.defaults.shortcut()``. This function has been moved 136 141 to ``django.contrib.contenttypes.views.shortcut()`` as part of the -
docs/ref/templates/builtins.txt
diff -r 9aed8047e568 docs/ref/templates/builtins.txt
a b 838 838 839 839 See also: ``{% include %}``. 840 840 841 .. admonition:: Forwards compatibility 842 843 .. versionchanged:: 1.3 844 845 In Django 1.5, the behavior of the :ttag:`ssi` template tag will 846 change, with the the first argument being made into a context 847 variable, rather than being a special case unquoted constant. This 848 will allow the :ttag:`ssi` tag to use a context variable as the 849 value of the page to be included. 850 851 In order to provide a forwards compatibility path, Django 1.3 852 provides a compatibility library -- ``future_ssi`` -- that 853 implements the new behavior. To use this library, add a 854 :ttag:`load` call at the top of any template using the :ttag:`ssi` 855 tag, and wrap the first argument to the :ttag:`ssi` tag in quotes. 856 For example:: 857 858 {% load future_ssi %} 859 {% ssi '/home/html/ljworld.com/includes/right_generic.html' %} 860 861 In Django 1.5, the unquoted constant behavior will be replaced 862 with the behavior provided by the ``future_ssi`` tag library. 863 Existing templates be migrated to use the new syntax. 864 841 865 .. templatetag:: templatetag 842 866 843 867 templatetag … … 955 979 {% url path.to.view arg,arg2 %} 956 980 {% url path.to.view arg, arg2 %} 957 981 958 This syntax doesn't support the use of literal commas, or orequals982 This syntax doesn't support the use of literal commas, or equals 959 983 signs. Did we mention you shouldn't use this syntax in any new 960 984 projects? 961 985 986 .. admonition:: Forwards compatibility 987 988 .. versionchanged:: 1.3 989 990 In Django 1.5, the behavior of the :ttag:`url` template tag will 991 change, with the the first argument being made into a context 992 variable, rather than being a special case unquoted constant. This 993 will allow the :ttag:`url` tag to use a context variable as the 994 value of the URL name to be reversed. 995 996 In order to provide a forwards compatibility path, Django 1.3 997 provides a compatibility library -- ``future_url`` -- that 998 implements the new behavior. To use this library, add a 999 :ttag:`load` call at the top of any template using the :ttag:`url` 1000 tag, and wrap the first argument to the :ttag:`url` tag in quotes. 1001 For example:: 1002 1003 {% load future_url %} 1004 {% url 'myapp:view-name' %} 1005 1006 The new library also formally deprecates the comma syntax for 1007 separating arguments to the :ttag:`url` template tag. 1008 1009 In Django 1.5, the old behavior will be replaced with the behavior 1010 provided by the ``future_url`` tag library. Existing templates be 1011 migrated to use the new syntax. 1012 962 1013 .. templatetag:: widthratio 963 1014 964 1015 widthratio -
docs/releases/1.3.txt
diff -r 9aed8047e568 docs/releases/1.3.txt
a b 341 341 redundancy, :class:`~django.test.simple.DjangoTestRunner` has been 342 342 turned into an empty placeholder class, and will be removed entirely 343 343 in Django 1.5. 344 345 Changes to :ttag:`url` and :ttag:`ssi` 346 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 347 348 inconsistency. Most template tags will allow you to pass in either 349 constants or variables as arguments -- for example:: 350 351 {% extends "base.html" %} 352 353 allows you to specify a base template as a constant, but if you have a 354 context variable ``templ`` that contains the value ``base.html``:: 355 356 {% extends templ %} 357 358 is also legal. 359 360 However, due to an accident of history, the :ttag:`url` and 361 :ttag:`ssi` are different. These tags use the second, quoteless 362 syntax, but interpret the argument as a constant. This means it isn't 363 possible to use a context variable as the target of a :ttag:`url` and 364 :ttag:`ssi` tag. 365 366 Django 1.3 marks the start of the process to correct this historical 367 accident. Django 1.3 adds two new template libraries -- ``future_url`` 368 and ``future_ssi`` -- which provide alternate implementations of the 369 :ttag:`url` and :ttag:`ssi` template tags. These ``future`` libraries 370 implement behavior that makes the handling of the first argument 371 consistent with the handling of all other variables. So, an existing 372 template that contains:: 373 374 {% url sample %} 375 376 should be replaced with:: 377 378 {% load future_url %} 379 {% url 'sample' %} 380 381 The tags implementing the old behavior have been deprecated, and in 382 Django 1.5, the old behavior will be replaced with the new behavior. 383 To ensure compatibility with future versions of Django, existing 384 templates should be modified to use the new ``future`` libraries and 385 syntax. -
new file tests/regressiontests/templates/templates/ssi_include.html
diff -r 9aed8047e568 tests/regressiontests/templates/templates/ssi_include.html
- + 1 This is for testing an ssi include. {{ test }} -
tests/regressiontests/templates/tests.py
diff -r 9aed8047e568 tests/regressiontests/templates/tests.py
a b 354 354 old_invalid = settings.TEMPLATE_STRING_IF_INVALID 355 355 expected_invalid_str = 'INVALID' 356 356 357 #Set ALLOWED_INCLUDE_ROOTS so that ssi works. 358 old_allowed_include_roots = settings.ALLOWED_INCLUDE_ROOTS 359 settings.ALLOWED_INCLUDE_ROOTS = os.path.dirname(os.path.abspath(__file__)) 360 357 361 # Warm the URL reversing cache. This ensures we don't pay the cost 358 362 # warming the cache during one of the tests. 359 363 urlresolvers.reverse('regressiontests.templates.views.client_action', … … 416 420 deactivate() 417 421 settings.TEMPLATE_DEBUG = old_td 418 422 settings.TEMPLATE_STRING_IF_INVALID = old_invalid 423 settings.ALLOWED_INCLUDE_ROOTS = old_allowed_include_roots 419 424 420 425 self.assertEqual(failures, [], "Tests failed:\n%s\n%s" % 421 426 ('-'*70, ("\n%s\n" % ('-'*70)).join(failures))) … … 1179 1184 '{% endfor %},' + \ 1180 1185 '{% endfor %}', 1181 1186 {}, ''), 1187 ### SSI TAG ######################################################## 1188 1189 # Test normal behavior 1190 'old-ssi01': ('{%% ssi %s %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'), 1191 'old-ssi02': ('{%% ssi %s %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {}, ''), 1192 1193 # Test parsed output 1194 'old-ssi06': ('{%% ssi %s parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'), 1195 'old-ssi07': ('{%% ssi %s parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {'test': 'Look ma! It parsed!'}, ''), 1196 1197 # Future compatibility 1198 # Test normal behavior 1199 'ssi01': ('{%% load future_ssi %%}{%% ssi "%s" %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'), 1200 'ssi02': ('{%% load future_ssi %%}{%% ssi "%s" %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {}, ''), 1201 'ssi03': ("{%% load future_ssi %%}{%% ssi '%s' %%}" % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {}, ''), 1202 1203 # Test passing as a variable 1204 'ssi04': ('{% load future_ssi %}{% ssi ssi_file %}', {'ssi_file': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html')}, 'This is for testing an ssi include. {{ test }}\n'), 1205 'ssi05': ('{% load future_ssi %}{% ssi ssi_file %}', {'ssi_file': 'no_file'}, ''), 1206 1207 # Test parsed output 1208 'ssi06': ('{%% load future_ssi %%}{%% ssi "%s" parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'), 1209 'ssi07': ('{%% load future_ssi %%}{%% ssi "%s" parsed %%}' % os.path.join(os.path.dirname(os.path.abspath(__file__)), 'not_here'), {'test': 'Look ma! It parsed!'}, ''), 1210 1182 1211 1183 1212 ### TEMPLATETAG TAG ####################################################### 1184 1213 'templatetag01': ('{% templatetag openblock %}', {}, '{%'), … … 1244 1273 'legacyurl16a': ("{% url regressiontests.templates.views.client_action action='update',id='1' %}", {}, '/url_tag/client/1/update/'), 1245 1274 'legacyurl17': ('{% url regressiontests.templates.views.client_action client_id=client.my_id,action=action %}', {'client': {'my_id': 1}, 'action': 'update'}, '/url_tag/client/1/update/'), 1246 1275 1247 ' url01': ('{% url regressiontests.templates.views.client client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'),1248 ' url02': ('{% url regressiontests.templates.views.client_action id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),1249 ' url02a': ('{% url regressiontests.templates.views.client_action client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'),1250 ' url02b': ("{% url regressiontests.templates.views.client_action id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),1251 ' url02c': ("{% url regressiontests.templates.views.client_action client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'),1252 ' url03': ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'),1253 ' url04': ('{% url named.client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'),1254 ' url05': (u'{% url метка_оператора v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),1255 ' url06': (u'{% url метка_оператора_2 tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),1256 ' url07': (u'{% url regressiontests.templates.views.client2 tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),1257 ' url08': (u'{% url метка_оператора v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),1258 ' url09': (u'{% url метка_оператора_2 tag=v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'),1259 ' url10': ('{% url regressiontests.templates.views.client_action id=client.id action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'),1260 ' url11': ('{% url regressiontests.templates.views.client_action id=client.id action="==" %}', {'client': {'id': 1}}, '/url_tag/client/1/==/'),1261 ' url12': ('{% url regressiontests.templates.views.client_action id=client.id action="," %}', {'client': {'id': 1}}, '/url_tag/client/1/,/'),1262 ' url13': ('{% url regressiontests.templates.views.client_action id=client.id action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),1263 ' url14': ('{% url regressiontests.templates.views.client_action client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'),1264 ' url15': ('{% url regressiontests.templates.views.client_action 12 "test" %}', {}, '/url_tag/client/12/test/'),1265 ' url18': ('{% url regressiontests.templates.views.client "1,2" %}', {}, '/url_tag/client/1,2/'),1276 'old-url01': ('{% url regressiontests.templates.views.client client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'), 1277 'old-url02': ('{% url regressiontests.templates.views.client_action id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1278 'old-url02a': ('{% url regressiontests.templates.views.client_action client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1279 'old-url02b': ("{% url regressiontests.templates.views.client_action id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1280 'old-url02c': ("{% url regressiontests.templates.views.client_action client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1281 'old-url03': ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'), 1282 'old-url04': ('{% url named.client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'), 1283 'old-url05': (u'{% url метка_оператора v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1284 'old-url06': (u'{% url метка_оператора_2 tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1285 'old-url07': (u'{% url regressiontests.templates.views.client2 tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1286 'old-url08': (u'{% url метка_оператора v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1287 'old-url09': (u'{% url метка_оператора_2 tag=v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1288 'old-url10': ('{% url regressiontests.templates.views.client_action id=client.id action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'), 1289 'old-url11': ('{% url regressiontests.templates.views.client_action id=client.id action="==" %}', {'client': {'id': 1}}, '/url_tag/client/1/==/'), 1290 'old-url12': ('{% url regressiontests.templates.views.client_action id=client.id action="," %}', {'client': {'id': 1}}, '/url_tag/client/1/,/'), 1291 'old-url13': ('{% url regressiontests.templates.views.client_action id=client.id action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1292 'old-url14': ('{% url regressiontests.templates.views.client_action client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1293 'old-url15': ('{% url regressiontests.templates.views.client_action 12 "test" %}', {}, '/url_tag/client/12/test/'), 1294 'old-url18': ('{% url regressiontests.templates.views.client "1,2" %}', {}, '/url_tag/client/1,2/'), 1266 1295 1267 1296 # Failures 1268 ' url-fail01': ('{% url %}', {}, template.TemplateSyntaxError),1269 ' url-fail02': ('{% url no_such_view %}', {}, urlresolvers.NoReverseMatch),1270 ' url-fail03': ('{% url regressiontests.templates.views.client %}', {}, urlresolvers.NoReverseMatch),1271 ' url-fail04': ('{% url view id, %}', {}, template.TemplateSyntaxError),1272 ' url-fail05': ('{% url view id= %}', {}, template.TemplateSyntaxError),1273 ' url-fail06': ('{% url view a.id=id %}', {}, template.TemplateSyntaxError),1274 ' url-fail07': ('{% url view a.id!id %}', {}, template.TemplateSyntaxError),1275 ' url-fail08': ('{% url view id="unterminatedstring %}', {}, template.TemplateSyntaxError),1276 ' url-fail09': ('{% url view id=", %}', {}, template.TemplateSyntaxError),1297 'old-url-fail01': ('{% url %}', {}, template.TemplateSyntaxError), 1298 'old-url-fail02': ('{% url no_such_view %}', {}, urlresolvers.NoReverseMatch), 1299 'old-url-fail03': ('{% url regressiontests.templates.views.client %}', {}, urlresolvers.NoReverseMatch), 1300 'old-url-fail04': ('{% url view id, %}', {}, template.TemplateSyntaxError), 1301 'old-url-fail05': ('{% url view id= %}', {}, template.TemplateSyntaxError), 1302 'old-url-fail06': ('{% url view a.id=id %}', {}, template.TemplateSyntaxError), 1303 'old-url-fail07': ('{% url view a.id!id %}', {}, template.TemplateSyntaxError), 1304 'old-url-fail08': ('{% url view id="unterminatedstring %}', {}, template.TemplateSyntaxError), 1305 'old-url-fail09': ('{% url view id=", %}', {}, template.TemplateSyntaxError), 1277 1306 1278 1307 # {% url ... as var %} 1279 'url-asvar01': ('{% url regressiontests.templates.views.index as url %}', {}, ''), 1280 'url-asvar02': ('{% url regressiontests.templates.views.index as url %}{{ url }}', {}, '/url_tag/'), 1281 'url-asvar03': ('{% url no_such_view as url %}{{ url }}', {}, ''), 1308 'old-url-asvar01': ('{% url regressiontests.templates.views.index as url %}', {}, ''), 1309 'old-url-asvar02': ('{% url regressiontests.templates.views.index as url %}{{ url }}', {}, '/url_tag/'), 1310 'old-url-asvar03': ('{% url no_such_view as url %}{{ url }}', {}, ''), 1311 1312 # forward compatibility 1313 # Successes 1314 'url01': ('{% load future_url %}{% url "regressiontests.templates.views.client" client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'), 1315 'url02': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1316 'url02a': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1317 'url02b': ("{% load future_url %}{% url 'regressiontests.templates.views.client_action' id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1318 'url02c': ("{% load future_url %}{% url 'regressiontests.templates.views.client_action' client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1319 'url03': ('{% load future_url %}{% url "regressiontests.templates.views.index" %}', {}, '/url_tag/'), 1320 'url04': ('{% load future_url %}{% url "named.client" client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'), 1321 'url05': (u'{% load future_url %}{% url "метка_оператора" v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1322 'url06': (u'{% load future_url %}{% url "метка_оператора_2" tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1323 'url07': (u'{% load future_url %}{% url "regressiontests.templates.views.client2" tag=v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1324 'url08': (u'{% load future_url %}{% url "метка_оператора" v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1325 'url09': (u'{% load future_url %}{% url "метка_оператора_2" tag=v %}', {'v': 'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 1326 'url10': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" id=client.id action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'), 1327 'url11': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" id=client.id action="==" %}', {'client': {'id': 1}}, '/url_tag/client/1/==/'), 1328 'url12': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" id=client.id action="," %}', {'client': {'id': 1}}, '/url_tag/client/1/,/'), 1329 'url13': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" id=client.id action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1330 'url14': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1331 'url15': ('{% load future_url %}{% url "regressiontests.templates.views.client_action" 12 "test" %}', {}, '/url_tag/client/12/test/'), 1332 'url18': ('{% load future_url %}{% url "regressiontests.templates.views.client" "1,2" %}', {}, '/url_tag/client/1,2/'), 1333 1334 'url19': ('{% load future_url %}{% url named_url client.id %}', {'named_url': 'regressiontests.templates.views.client', 'client': {'id': 1}}, '/url_tag/client/1/'), 1335 1336 # Failures 1337 'url-fail01': ('{% load future_url %}{% url %}', {}, template.TemplateSyntaxError), 1338 'url-fail02': ('{% load future_url %}{% url "no_such_view" %}', {}, urlresolvers.NoReverseMatch), 1339 'url-fail03': ('{% load future_url %}{% url "regressiontests.templates.views.client" %}', {}, urlresolvers.NoReverseMatch), 1340 'url-fail04': ('{% load future_url %}{% url "view" id, %}', {}, template.TemplateSyntaxError), 1341 'url-fail05': ('{% load future_url %}{% url "view" id= %}', {}, template.TemplateSyntaxError), 1342 'url-fail06': ('{% load future_url %}{% url "view" a.id=id %}', {}, template.TemplateSyntaxError), 1343 'url-fail07': ('{% load future_url %}{% url "view" a.id!id %}', {}, template.TemplateSyntaxError), 1344 'url-fail08': ('{% load future_url %}{% url "view" id="unterminatedstring %}', {}, template.TemplateSyntaxError), 1345 'url-fail09': ('{% load future_url %}{% url "view" id=", %}', {}, template.TemplateSyntaxError), 1346 1347 'url-fail11': ('{% load future_url %}{% url named_url %}', {}, urlresolvers.NoReverseMatch), 1348 'url-fail12': ('{% load future_url %}{% url named_url %}', {'named_url': 'no_such_view'}, urlresolvers.NoReverseMatch), 1349 'url-fail13': ('{% load future_url %}{% url named_url %}', {'named_url': 'regressiontests.templates.views.client'}, urlresolvers.NoReverseMatch), 1350 'url-fail14': ('{% load future_url %}{% url named_url id, %}', {'named_url': 'view'}, template.TemplateSyntaxError), 1351 'url-fail15': ('{% load future_url %}{% url named_url id= %}', {'named_url': 'view'}, template.TemplateSyntaxError), 1352 'url-fail16': ('{% load future_url %}{% url named_url a.id=id %}', {'named_url': 'view'}, template.TemplateSyntaxError), 1353 'url-fail17': ('{% load future_url %}{% url named_url a.id!id %}', {'named_url': 'view'}, template.TemplateSyntaxError), 1354 'url-fail18': ('{% load future_url %}{% url named_url id="unterminatedstring %}', {'named_url': 'view'}, template.TemplateSyntaxError), 1355 'url-fail19': ('{% load future_url %}{% url named_url id=", %}', {'named_url': 'view'}, template.TemplateSyntaxError), 1356 1357 # {% url ... as var %} 1358 'url-asvar01': ('{% load future_url %}{% url "regressiontests.templates.views.index" as url %}', {}, ''), 1359 'url-asvar02': ('{% load future_url %}{% url "regressiontests.templates.views.index" as url %}{{ url }}', {}, '/url_tag/'), 1360 'url-asvar03': ('{% load future_url %}{% url "no_such_view" as url %}{{ url }}', {}, ''), 1282 1361 1283 1362 ### CACHE TAG ###################################################### 1284 1363 'cache01': ('{% load cache %}{% cache -1 test %}cache01{% endcache %}', {}, 'cache01'),