X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/a79b7c9e4f8038db3795b482c78b2c6d7f64bebb..ba4bab73996c40c2551f7e5a0e478d0f553b8af3:/models/nodes.py?ds=inline diff --git a/models/nodes.py b/models/nodes.py index 10c51b4..3f40205 100644 --- a/models/nodes.py +++ b/models/nodes.py @@ -114,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) @@ -219,15 +219,24 @@ class TargetURLModel(models.Model): try: self.get_target_url() - except NoReverseMatch, e: + except (NoReverseMatch, ViewCanNotProvideSubpath), e: raise ValidationError(e.message) super(TargetURLModel, self).clean() def get_reverse_params(self): params = self.reversing_parameters - args = isinstance(params, list) and params or None - kwargs = isinstance(params, dict) and params or None + args = kwargs = None + if isinstance(params, list): + args = params + elif isinstance(params, dict): + # Convert unicode keys to strings for Python < 2.6.5. Compare + # http://stackoverflow.com/questions/4598604/how-to-pass-unicode-keywords-to-kwargs + kwargs = {} + for key, val in params.items(): + if isinstance(key, unicode): + key = str(key) + kwargs[key] = val return self.url_or_subpath, args, kwargs def get_target_url(self):