Ticket #13275: 13275.diff
File 13275.diff, 7.1 KB (added by , 15 years ago) |
---|
-
tests/regressiontests/templates/urls.py
### Eclipse Workspace Patch 1.0 #P Django
6 6 7 7 # Test urls for testing reverse lookups 8 8 (r'^$', views.index), 9 (r'^client/( \d+)/$', views.client),9 (r'^client/([\d,]+)/$', views.client), 10 10 (r'^client/(?P<id>\d+)/(?P<action>[^/]+)/$', views.client_action), 11 (r'^client/(?P<client_id>\d+)/(?P<action>[^/]+)/$', views.client_action), 11 12 url(r'^named-client/(\d+)/$', views.client2, name="named.client"), 12 13 13 14 # Unicode strings are permitted everywhere. -
tests/regressiontests/templates/tests.py
364 364 settings.TEMPLATE_STRING_IF_INVALID = invalid_str 365 365 for is_cached in (False, True): 366 366 try: 367 start = datetime.now() 367 368 test_template = loader.get_template(name) 369 end = datetime.now() 368 370 output = self.render(test_template, vals) 371 if end-start > timedelta(seconds=0.1): 372 failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Took too long to parse test" % (is_cached, invalid_str, name)) 369 373 except ContextStackException: 370 374 failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s'): %s -- FAILED. Context stack was left imbalanced" % (is_cached, invalid_str, name)) 371 375 continue … … 1175 1179 # Successes 1176 1180 'legacyurl02': ('{% url regressiontests.templates.views.client_action id=client.id,action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1177 1181 'legacyurl02a': ('{% url regressiontests.templates.views.client_action client.id,"update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1182 'legacyurl02b': ("{% url regressiontests.templates.views.client_action id=client.id,action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1183 'legacyurl02c': ("{% url regressiontests.templates.views.client_action client.id,'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1178 1184 'legacyurl10': ('{% url regressiontests.templates.views.client_action id=client.id,action="two words" %}', {'client': {'id': 1}}, '/url_tag/client/1/two%20words/'), 1179 1185 'legacyurl13': ('{% url regressiontests.templates.views.client_action id=client.id, action=arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1180 1186 'legacyurl14': ('{% url regressiontests.templates.views.client_action client.id, arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1187 'legacyurl16': ('{% url regressiontests.templates.views.client_action action="update",id="1" %}', {}, '/url_tag/client/1/update/'), 1188 'legacyurl16a': ("{% url regressiontests.templates.views.client_action action='update',id='1' %}", {}, '/url_tag/client/1/update/'), 1189 '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/'), 1181 1190 1182 1191 'url01': ('{% url regressiontests.templates.views.client client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'), 1183 1192 'url02': ('{% url regressiontests.templates.views.client_action id=client.id action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1184 1193 'url02a': ('{% url regressiontests.templates.views.client_action client.id "update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1194 'url02b': ("{% url regressiontests.templates.views.client_action id=client.id action='update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1195 'url02c': ("{% url regressiontests.templates.views.client_action client.id 'update' %}", {'client': {'id': 1}}, '/url_tag/client/1/update/'), 1185 1196 'url03': ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'), 1186 1197 'url04': ('{% url named.client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'), 1187 1198 'url05': (u'{% url метка_оператора v %}', {'v': u'Ω'}, '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), … … 1195 1206 '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/'), 1196 1207 'url14': ('{% url regressiontests.templates.views.client_action client.id arg|join:"-" %}', {'client': {'id': 1}, 'arg':['a','b']}, '/url_tag/client/1/a-b/'), 1197 1208 'url15': ('{% url regressiontests.templates.views.client_action 12 "test" %}', {}, '/url_tag/client/12/test/'), 1209 'url18': ('{% url regressiontests.templates.views.client "1,2" %}', {}, '/url_tag/client/1,2/'), 1198 1210 1199 1211 # Failures 1200 1212 'url-fail01': ('{% url %}', {}, template.TemplateSyntaxError), -
django/template/defaulttags.py
1065 1065 return TemplateTagNode(tag) 1066 1066 templatetag = register.tag(templatetag) 1067 1067 1068 # Backwards compatibility check which will fail against for old comma1069 # separated arguments in the url tag.1070 url_backwards_re = re.compile(r'''(('[^']*'|"[^"]*"|[^,]+)=?)+$''')1071 1072 1068 def url(parser, token): 1073 1069 """ 1074 1070 Returns an absolute URL matching given view with its parameters. … … 1117 1113 asvar = bits[-1] 1118 1114 bits = bits[:-2] 1119 1115 1120 # Backwards compatibility: {% url urlname arg1,arg2 %} or 1121 # {% url urlname arg1,arg2 as foo %} cases. 1122 if bits: 1123 old_args = ''.join(bits) 1124 if not url_backwards_re.match(old_args): 1125 bits = old_args.split(",") 1116 # Backwards compatibility: check for the old comma separated format 1117 # {% url urlname arg1,arg2 %} 1118 if bits and ',' in bits[0]: 1119 check_old_format = True 1120 for bit in bits[1:-1]: 1121 if ',' not in bit: 1122 check_old_format = False 1123 break 1124 else: 1125 check_old_format = False 1126 if check_old_format: 1127 match = kwarg_re.match(bits[0]) 1128 if match: 1129 value = match.groups()[1] 1130 # Check for the old format by trying to parse the first argument. An 1131 # exception will be raised if the comma is unexpected (i.e. outside 1132 # of a static string). 1133 try: 1134 parser.compile_filter(value) 1135 except TemplateSyntaxError: 1136 bits = ''.join(bits).split(',') 1126 1137 1127 1138 if len(bits): 1128 1139 for bit in bits: