On Thu, 2009-03-05 at 10:56 -0800, adrian wrote:
> 
> I've had some problems with reverse and have some questions and
> thoughts:
> 
> 1. When I add a view and a corresponding entry in urls,py, sometimes I
> get a reverse error until I stop the dev server and restart it, even
> though nothing is wrong with either file.   Is there an order in which
> those changes should be made that guarantees this won't happen?
> 
> 2. The doc says templates are intended to be editable by designers/non-
> programmers.   But any {% url view arg %} tag that is not 100% correct
> (both view and arg) will bring down that page, not just cause a broken
> link.
> The error message usually points to the first {% url %} tag, which may
> be in a base template not in the template that actually contains the
> error.

Well, some people (and this is the view that has prevailed in putting
this change into the code a while back) view a url tag error like this
equivalent to a syntax error. Which is a fatal error that should be
detected in testing.

I, for one, don't agree with the current decision --I think the url tag
should fail silently because it's not possible to exhaustively test it
before rollout -- but that's the way it is.

> 3. The details given in the error messages for reverse are very
> misleading.   The error is almost always elsewhere and the arguments
> are usually irrelevant. 

That's not generally true. It might well be what you're observing in
your particular cases, but typically the error is actually very
accurate: it's telling you the view name it's been asked to search for
and the arguments that have been provided and is saying it cannot find
that. The arguments are very relevant, since that's what is being looked
for and if they don't match what you expect, that helps you debug. If
they do match what you expect, that tells you to examine your URL
patterns to see why they aren't being matched.

>   It is not good policy to imply a specific
> error location when the error system has no idea where the problem
> is.

We do the best we can. As noted, the error is actually accurate in
telling you the view and arguments it has been asked to look for and it
failed at that request.

> 
> 4.  One improvement would be something (in the dev server?) that does
> some basic comparison of urls.py and views.   Django  has access to
> all the URL patterns and all the views modules, so couldn't it compare
> the views in one to the views in the other and warn you if there is a
> mismatch?   This would not require reversing the Regexes, just making
> sure the view functions referenced in urls.py are all present in
> views.    That would localize one source of reverse errors.

Patches welcome.

> 5.  If the checking specified in #4 finds no errors, wouldn't that
> mean the error must be in the template? 

No. It could be in the parameters.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to