Changeset 5530
- Timestamp:
- 06/24/07 23:34:34 (1 year ago)
- Files:
-
- django/trunk/django/core/urlresolvers.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/templates/tests.py (modified) (1 diff)
- django/trunk/tests/regressiontests/templates/urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/urlresolvers.py
r5520 r5530 28 28 silent_variable_failure = True 29 29 30 def get_callable(lookup_view): 30 def get_callable(lookup_view, can_fail=False): 31 """ 32 Convert a string version of a function name to the callable object. 33 34 If the lookup_view is not an import path, it is assumed to be a URL pattern 35 label and the original string is returned. 36 37 If can_fail is True, lookup_view might be a URL pattern label, so errors 38 during the import fail and the string is returned. 39 """ 31 40 if not callable(lookup_view): 32 41 mod_name, func_name = get_mod_func(lookup_view) 33 if func_name != '': 34 lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name) 42 try: 43 if func_name != '': 44 lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name) 45 except (ImportError, AttributeError): 46 if not can_fail: 47 raise 35 48 return lookup_view 36 49 get_callable = memoize(get_callable, _callable_cache) … … 249 262 def reverse(self, lookup_view, *args, **kwargs): 250 263 try: 251 lookup_view = get_callable(lookup_view )264 lookup_view = get_callable(lookup_view, True) 252 265 except (ImportError, AttributeError): 253 266 raise NoReverseMatch django/trunk/tests/regressiontests/templates/tests.py
r5443 r5530 726 726 'url02' : ('{% url regressiontests.templates.views.client_action client.id, action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), 727 727 'url03' : ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'), 728 'url04' : ('{% url named -client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'),728 'url04' : ('{% url named.client client.id %}', {'client': {'id': 1}}, '/url_tag/named-client/1/'), 729 729 730 730 # Failures django/trunk/tests/regressiontests/templates/urls.py
r4901 r5530 8 8 (r'^client/(\d+)/$', views.client), 9 9 (r'^client/(\d+)/(?P<action>[^/]+)/$', views.client_action), 10 url(r'^named-client/(\d+)/$', views.client, name="named -client"),10 url(r'^named-client/(\d+)/$', views.client, name="named.client"), 11 11 )
