X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/06dc22d5cbde2329fe2e5926243697e492b0a9ef..76d3c448fe7e5d3350690bb989476a921f156b23:/models/nodes.py diff --git a/models/nodes.py b/models/nodes.py index 8d33d43..07a5e0a 100644 --- a/models/nodes.py +++ b/models/nodes.py @@ -3,6 +3,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django.contrib.sites.models import Site, RequestSite from django.http import HttpResponse, HttpResponseServerError, HttpResponseRedirect, Http404 +from django.core.exceptions import ValidationError from django.core.servers.basehttp import FileWrapper from django.core.urlresolvers import resolve, clear_url_caches, reverse, NoReverseMatch from django.template import add_to_builtins as register_templatetags @@ -113,8 +114,8 @@ class View(Entity): try: subpath = reverse(view_name, urlconf=self, args=args or [], kwargs=kwargs or {}) - except NoReverseMatch: - raise ViewCanNotProvideSubpath + except NoReverseMatch, e: + raise ViewCanNotProvideSubpath(e.message) if node is not None: return node.construct_url(subpath) @@ -218,7 +219,7 @@ class TargetURLModel(models.Model): try: self.get_target_url() - except NoReverseMatch, e: + except (NoReverseMatch, ViewCanNotProvideSubpath), e: raise ValidationError(e.message) super(TargetURLModel, self).clean() @@ -233,7 +234,7 @@ class TargetURLModel(models.Model): node = self.target_node if node is not None and node.accepts_subpath and self.url_or_subpath: if self.reversing_parameters is not None: - view_name, args, kwargs = self.get_reversing_params() + view_name, args, kwargs = self.get_reverse_params() subpath = node.view.reverse(view_name, args=args, kwargs=kwargs) else: subpath = self.url_or_subpath @@ -244,7 +245,7 @@ class TargetURLModel(models.Model): return node.get_absolute_url() else: if self.reversing_parameters is not None: - view_name, args, kwargs = self.get_reversing_params() + view_name, args, kwargs = self.get_reverse_params() return reverse(view_name, args=args, kwargs=kwargs) return self.url_or_subpath target_url = property(get_target_url)