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
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 """Controllers for the tracim application."""
2
 """Controllers for the tracim application."""
3
+from sqlalchemy.orm.exc import NoResultFound
4
+from tg import abort
3
 from tracim.lib.workspace import WorkspaceApi
5
 from tracim.lib.workspace import WorkspaceApi
4
 
6
 
5
 import tg
7
 import tg
167
     /dashboard/workspaces/{}/folders/{}/someitems/{}
169
     /dashboard/workspaces/{}/folders/{}/someitems/{}
168
     """
170
     """
169
     def _before(self, *args, **kw):
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
     @property
179
     @property
176
     def _std_url(self):
180
     def _std_url(self):