Browse Source

Closes #89: TIMWorkspaceContentRestController: Raise 404 error if ressource not found

Bastien Sevajol (Algoo) 8 years ago
parent
commit
915c40bf72
1 changed files with 8 additions and 4 deletions
  1. 8 4
      tracim/tracim/controllers/__init__.py

+ 8 - 4
tracim/tracim/controllers/__init__.py View File

@@ -1,5 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 """Controllers for the tracim application."""
3
+from sqlalchemy.orm.exc import NoResultFound
4
+from tg import abort
3 5
 from tracim.lib.workspace import WorkspaceApi
4 6
 
5 7
 import tg
@@ -167,10 +169,12 @@ class TIMWorkspaceContentRestController(TIMRestControllerWithBreadcrumb):
167 169
     /dashboard/workspaces/{}/folders/{}/someitems/{}
168 170
     """
169 171
     def _before(self, *args, **kw):
170
-        TIMRestPathContextSetup.current_user()
171
-        TIMRestPathContextSetup.current_workspace()
172
-        TIMRestPathContextSetup.current_folder()
173
-
172
+        try:
173
+            TIMRestPathContextSetup.current_user()
174
+            TIMRestPathContextSetup.current_workspace()
175
+            TIMRestPathContextSetup.current_folder()
176
+        except NoResultFound:
177
+            abort(404)
174 178
 
175 179
     @property
176 180
     def _std_url(self):