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
8d260814
Commit
8d260814
authored
Aug 05, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honor Flask application debug flag. Improves situation with #277
parent
c9a0dbcd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
1 deletion
+52
-1
base.py
flask_admin/base.py
+12
-1
view.py
flask_admin/contrib/mongoengine/view.py
+12
-0
view.py
flask_admin/contrib/peewee/view.py
+12
-0
view.py
flask_admin/contrib/sqla/view.py
+13
-0
base.py
flask_admin/model/base.py
+3
-0
No files found.
flask_admin/base.py
View file @
8d260814
...
...
@@ -137,7 +137,8 @@ class BaseView(with_metaclass(AdminViewMeta, BaseViewClass)):
return
args
def
__init__
(
self
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
,
static_folder
=
None
,
static_url_path
=
None
):
def
__init__
(
self
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
,
static_folder
=
None
,
static_url_path
=
None
):
"""
Constructor.
...
...
@@ -157,6 +158,9 @@ class BaseView(with_metaclass(AdminViewMeta, BaseViewClass)):
and '/admin/' prefix won't be applied.
:param static_url_path:
Static URL Path. If provided, this specifies the path to the static url directory.
:param debug:
Optional debug flag. If set to `True`, will rethrow exceptions in some cases, so Werkzeug
debugger can catch them.
"""
self
.
name
=
name
self
.
category
=
category
...
...
@@ -295,6 +299,13 @@ class BaseView(with_metaclass(AdminViewMeta, BaseViewClass)):
if
not
self
.
is_accessible
():
return
abort
(
404
)
@
property
def
_debug
(
self
):
if
not
self
.
admin
or
not
self
.
admin
.
app
:
return
False
return
self
.
admin
.
app
.
debug
class
AdminIndexView
(
BaseView
):
"""
...
...
flask_admin/contrib/mongoengine/view.py
View file @
8d260814
...
...
@@ -363,6 +363,9 @@ class ModelView(BaseModelView):
self
.
_on_model_change
(
form
,
model
,
True
)
model
.
save
()
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to create model.
%(error)
s'
,
error
=
format_error
(
ex
)),
'error'
)
...
...
@@ -387,6 +390,9 @@ class ModelView(BaseModelView):
self
.
_on_model_change
(
form
,
model
,
False
)
model
.
save
()
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to update model.
%(error)
s'
,
error
=
format_error
(
ex
)),
'error'
)
...
...
@@ -409,6 +415,9 @@ class ModelView(BaseModelView):
model
.
delete
()
return
True
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to delete model.
%(error)
s'
,
error
=
format_error
(
ex
)),
'error'
)
...
...
@@ -461,5 +470,8 @@ class ModelView(BaseModelView):
count
,
count
=
count
))
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to delete models.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
flask_admin/contrib/peewee/view.py
View file @
8d260814
...
...
@@ -341,6 +341,9 @@ class ModelView(BaseModelView):
# For peewee have to save inline forms after model was saved
save_inline
(
form
,
model
)
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to create model.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
logging
.
exception
(
'Failed to create model'
)
return
False
...
...
@@ -358,6 +361,9 @@ class ModelView(BaseModelView):
# For peewee have to save inline forms after model was saved
save_inline
(
form
,
model
)
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to update model.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
logging
.
exception
(
'Failed to update model'
)
return
False
...
...
@@ -372,6 +378,9 @@ class ModelView(BaseModelView):
model
.
delete_instance
(
recursive
=
True
)
return
True
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to delete model.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
logging
.
exception
(
'Failed to delete model'
)
return
False
...
...
@@ -407,4 +416,7 @@ class ModelView(BaseModelView):
count
,
count
=
count
))
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to delete models.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
flask_admin/contrib/sqla/view.py
View file @
8d260814
...
...
@@ -768,6 +768,9 @@ class ModelView(BaseModelView):
self
.
_on_model_change
(
form
,
model
,
True
)
self
.
session
.
commit
()
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to create model.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
logging
.
exception
(
'Failed to create model'
)
self
.
session
.
rollback
()
...
...
@@ -791,9 +794,13 @@ class ModelView(BaseModelView):
self
.
_on_model_change
(
form
,
model
,
False
)
self
.
session
.
commit
()
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to update model.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
logging
.
exception
(
'Failed to update model'
)
self
.
session
.
rollback
()
return
False
else
:
self
.
after_model_change
(
form
,
model
,
False
)
...
...
@@ -814,6 +821,9 @@ class ModelView(BaseModelView):
self
.
session
.
commit
()
return
True
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to delete model.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
logging
.
exception
(
'Failed to delete model'
)
self
.
session
.
rollback
()
...
...
@@ -852,4 +862,7 @@ class ModelView(BaseModelView):
count
,
count
=
count
))
except
Exception
as
ex
:
if
self
.
_debug
:
raise
flash
(
gettext
(
'Failed to delete models.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
flask_admin/model/base.py
View file @
8d260814
...
...
@@ -396,6 +396,9 @@ class BaseModelView(BaseView, ActionsMixin):
'userview'
:param url:
Base URL. If not provided, will use endpoint as a URL.
:param debug:
Enable debugging mode. Won't catch exceptions on model
save failures.
"""
# If name not provided, it is model name
...
...
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