Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
44438d87
Commit
44438d87
authored
Jun 08, 2016
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1293 from jmagnusson/raise-on-error
Allow exceptions to always be raised on view errors
parents
5a5001b4
371a8384
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
view.py
flask_admin/contrib/sqla/view.py
+5
-2
base.py
flask_admin/model/base.py
+5
-2
setup.py
setup.py
+1
-0
No files found.
flask_admin/contrib/sqla/view.py
View file @
44438d87
...
...
@@ -10,7 +10,7 @@ from sqlalchemy.exc import IntegrityError
from
sqlalchemy.sql.expression
import
cast
from
sqlalchemy
import
Unicode
from
flask
import
flash
from
flask
import
current_app
,
flash
from
flask_admin._compat
import
string_types
,
text_type
from
flask_admin.babel
import
gettext
,
ngettext
,
lazy_gettext
...
...
@@ -996,7 +996,10 @@ class ModelView(BaseModelView):
# Error handler
def
handle_view_exception
(
self
,
exc
):
if
isinstance
(
exc
,
IntegrityError
):
flash
(
gettext
(
'Integrity error.
%(message)
s'
,
message
=
text_type
(
exc
)),
'error'
)
if
current_app
.
config
.
get
(
'ADMIN_RAISE_ON_VIEW_EXCEPTION'
):
raise
else
:
flash
(
gettext
(
'Integrity error.
%(message)
s'
,
message
=
text_type
(
exc
)),
'error'
)
return
True
return
super
(
ModelView
,
self
)
.
handle_view_exception
(
exc
)
...
...
flask_admin/model/base.py
View file @
44438d87
...
...
@@ -7,8 +7,8 @@ from math import ceil
from
werkzeug
import
secure_filename
from
flask
import
(
request
,
redirect
,
flash
,
abort
,
json
,
Response
,
get_flashed_messages
,
stream_with_context
)
from
flask
import
(
current_app
,
request
,
redirect
,
flash
,
abort
,
json
,
Response
,
get_flashed_messages
,
stream_with_context
)
from
jinja2
import
contextfunction
try
:
import
tablib
...
...
@@ -1441,6 +1441,9 @@ class BaseModelView(BaseView, ActionsMixin):
flash
(
as_unicode
(
exc
),
'error'
)
return
True
if
current_app
.
config
.
get
(
'ADMIN_RAISE_ON_VIEW_EXCEPTION'
):
raise
if
self
.
_debug
:
raise
...
...
setup.py
View file @
44438d87
...
...
@@ -73,6 +73,7 @@ setup(
'Programming Language :: Python :: 2.6'
,
'Programming Language :: Python :: 3.3'
,
'Programming Language :: Python :: 3.4'
,
'Programming Language :: Python :: 3.5'
,
],
test_suite
=
'nose.collector'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment