diff options
author | Aaron Bentley <abentley@panoramicfeedback.com> | 2006-04-12 10:38:01 -0400 |
---|---|---|
committer | Aaron Bentley <abentley@panoramicfeedback.com> | 2006-04-12 10:38:01 -0400 |
commit | 17694fa83dbb2e237173de89610c82988405ca37 (patch) | |
tree | 7862acb787bcf9223078e09e7a5eb63e1b42d662 | |
parent | 313a51b173bf7c9caadd1480911ec5809ae14501 (diff) | |
download | bugseverywhere-17694fa83dbb2e237173de89610c82988405ca37.tar.gz |
Teach PrestHandler to handle bad paths cleanly
-rw-r--r-- | Bugs-Everywhere-Web/beweb/prest.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Bugs-Everywhere-Web/beweb/prest.py b/Bugs-Everywhere-Web/beweb/prest.py index e6b7cdf..9a6505d 100644 --- a/Bugs-Everywhere-Web/beweb/prest.py +++ b/Bugs-Everywhere-Web/beweb/prest.py @@ -1,5 +1,6 @@ from unittest import TestCase import unittest +from cherrypy import NotFound """A pseudo-REST dispatching method in which only the noun comes from the path. The action performed will depend on kwargs. """ @@ -43,12 +44,20 @@ class PrestHandler(object): if len(path) == 0: resource = None else: - resource = self.instantiate(**data) + try: + resource = self.instantiate(**data) + except NotImplementedError, e: + if e.args[0] is not PrestHandler.instantiate: + raise NotFound() + return self, resource, data, path[1:] if len(path) > 2: data[path[1]] = path[2] return getattr(self, path[1]).decode(path[2:], data) + def instantiate(self, **date): + raise NotImplementedError(PrestHandler.instantiate) + def default(self, *args, **kwargs): child, resource, data, extra = self.decode([None,] + list(args)) action = child.get_action(**kwargs) |