Pārlūkot izejas kodu

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

Bastien Sevajol (Algoo) 8 gadus atpakaļ
vecāks
revīzija
915c40bf72
1 mainītis faili ar 8 papildinājumiem un 4 dzēšanām
  1. 8 4
      tracim/tracim/controllers/__init__.py

+ 8 - 4
tracim/tracim/controllers/__init__.py Parādīt failu

@@ -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):