Handling new pydal Exceptions in response.download
This commit is contained in:
@@ -597,6 +597,7 @@ class Response(Storage):
|
|||||||
|
|
||||||
Downloads from http://..../download/filename
|
Downloads from http://..../download/filename
|
||||||
"""
|
"""
|
||||||
|
from pydal.exceptions import NotAuthorizedException, NotFoundException
|
||||||
|
|
||||||
current.session.forget(current.response)
|
current.session.forget(current.response)
|
||||||
|
|
||||||
@@ -613,6 +614,10 @@ class Response(Storage):
|
|||||||
raise HTTP(404)
|
raise HTTP(404)
|
||||||
try:
|
try:
|
||||||
(filename, stream) = field.retrieve(name, nameonly=True)
|
(filename, stream) = field.retrieve(name, nameonly=True)
|
||||||
|
except NotAuthorizedException:
|
||||||
|
raise HTTP(403)
|
||||||
|
except NotFoundException:
|
||||||
|
raise HTTP(404)
|
||||||
except IOError:
|
except IOError:
|
||||||
raise HTTP(404)
|
raise HTTP(404)
|
||||||
headers = self.headers
|
headers = self.headers
|
||||||
|
|||||||
Reference in New Issue
Block a user