Author: jacob
Date: 2008-08-28 14:05:14 -0500 (Thu, 28 Aug 2008)
New Revision: 8672

Modified:
   django/trunk/AUTHORS
   django/trunk/django/core/urlresolvers.py
Log:
Fixed #8221: added some better `NoReverseMatch` error strings. Thanks, mrts.

Modified: django/trunk/AUTHORS
===================================================================
--- django/trunk/AUTHORS        2008-08-28 17:26:16 UTC (rev 8671)
+++ django/trunk/AUTHORS        2008-08-28 19:05:14 UTC (rev 8672)
@@ -383,6 +383,7 @@
     Swaroop C H <http://www.swaroopch.info>
     Aaron Swartz <http://www.aaronsw.com/>
     Ville Säävuori <http://www.unessa.net/>
+    Mart Sõmermaa <http://mrts.pri.ee/>
     Christian Tanzer <[EMAIL PROTECTED]>
     Tyler Tarabula <[EMAIL PROTECTED]>
     Tyson Tate <[EMAIL PROTECTED]>

Modified: django/trunk/django/core/urlresolvers.py
===================================================================
--- django/trunk/django/core/urlresolvers.py    2008-08-28 17:26:16 UTC (rev 
8671)
+++ django/trunk/django/core/urlresolvers.py    2008-08-28 19:05:14 UTC (rev 
8672)
@@ -52,6 +52,8 @@
             mod_name, func_name = get_mod_func(lookup_view)
             if func_name != '':
                 lookup_view = getattr(__import__(mod_name, {}, {}, ['']), 
func_name)
+                if not callable(lookup_view):
+                    raise AttributeError("'%s.%s' is not a callable." % 
(mod_name, func_name))
         except (ImportError, AttributeError):
             if not can_fail:
                 raise
@@ -196,10 +198,12 @@
         mod_name, func_name = get_mod_func(viewname)
         try:
             lookup_view = getattr(__import__(mod_name, {}, {}, ['']), 
func_name)
-        except (ImportError, AttributeError):
-            raise NoReverseMatch
+        except ImportError, e:
+            raise NoReverseMatch("Could not import '%s': %s" % (mod_name, e))
+        except AttributeError, e:
+            raise NoReverseMatch("'%s' has no attribute '%s'" % (mod_name, 
func_name))
         if lookup_view != self.callback:
-            raise NoReverseMatch
+            raise NoReverseMatch("Reversed view '%s' doesn't match the 
expected callback ('%s')." % (viewname, self.callback))
         return self.reverse_helper(*args, **kwargs)
 
     def reverse_helper(self, *args, **kwargs):
@@ -279,11 +283,12 @@
     def reverse(self, lookup_view, *args, **kwargs):
         try:
             lookup_view = get_callable(lookup_view, True)
-        except (ImportError, AttributeError):
-            raise NoReverseMatch("'%s' is not a callable." % lookup_view)
+        except (ImportError, AttributeError), e:
+            raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, 
e))
         if lookup_view in self.reverse_dict:
             return u''.join([reverse_helper(part.regex, *args, **kwargs) for 
part in self.reverse_dict[lookup_view]])
-        raise NoReverseMatch("Reverse for '%s' not found." % lookup_view)
+        raise NoReverseMatch("Reverse for '%s' with arguments '%s' and keyword 
"
+                "arguments '%s' not found." % (lookup_view, args, kwargs))
 
     def reverse_helper(self, lookup_view, *args, **kwargs):
         sub_match = self.reverse(lookup_view, *args, **kwargs)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to