diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-11-01 18:27:25 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-11-01 18:27:25 (GMT) |
commit | 67ff87040acab94df7e951736395e3a6bf0b34fd (patch) | |
tree | fb097f800b9af50bc61584fdfbaecda2b5ba09b6 | |
parent | 576c1f99c29f3d344179e4c224702b1ebfc37bfb (diff) |
Special exception class for bad request path
-rw-r--r-- | active_document/__init__.py | 2 | ||||
-rw-r--r-- | active_document/env.py | 5 | ||||
-rw-r--r-- | active_document/volume.py | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/active_document/__init__.py b/active_document/__init__.py index 9496300..cf21a3a 100644 --- a/active_document/__init__.py +++ b/active_document/__init__.py @@ -20,7 +20,7 @@ from active_document.env import ACCESS_CREATE, ACCESS_WRITE, ACCESS_READ, \ ACCESS_LEVELS, ACCESS_SYSTEM, ACCESS_LOCAL, ACCESS_REMOTE, \ index_flush_timeout, index_flush_threshold, \ index_write_queue, \ - NotFound, Forbidden, Seqno, DEFAULT_LANG, \ + BadRequest, NotFound, Forbidden, Seqno, DEFAULT_LANG, \ uuid, default_lang from active_document.metadata import Metadata, PropertyMeta, Property, \ diff --git a/active_document/env.py b/active_document/env.py index dbf24c0..debf81b 100644 --- a/active_document/env.py +++ b/active_document/env.py @@ -95,6 +95,11 @@ def default_lang(): return DEFAULT_LANG +class BadRequest(Exception): + """Bad requested resource.""" + pass + + class NotFound(Exception): """Resource was not found.""" pass diff --git a/active_document/volume.py b/active_document/volume.py index ebab01c..70f3341 100644 --- a/active_document/volume.py +++ b/active_document/volume.py @@ -99,7 +99,8 @@ class _Volume(dict): def __getitem__(self, name): directory = self.get(name) if directory is None: - enforce(name in self._to_open, 'Unknown %r document', name) + enforce(name in self._to_open, env.BadRequest, + 'Unknown %r document', name) directory = self[name] = self._open(name, self._to_open.pop(name)) return directory |