You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementing this to flask admin would allow a more flexible decoration of the admin views :)
Could something like this work in Admin class, with BaseView having a default class attribute for decorators?
class Admin:
....
def init_app
...
for view in self._views:
blueprint = view.create_blueprint(self)
for decorator in view.decorators:
blueprint.before_request(decorator(blueprint))
app.register_blueprint(blueprint)
The text was updated successfully, but these errors were encountered:
sergioisidoro
changed the title
[feature request] Add method views akin to Falsk
[feature request] Add decorators to views akin to Flask Method views
Jul 15, 2021
Decorators are already baked into ModelViews (note the @expose uses throughout the documentation). It doesn't make sense to expose decorators to all ModelView functions because most of the functions have nothing to do with routing. Since you have to explicitly use @expose on routes within a ModelView blueprint in order to make them accessible you might as well add the extra decorator to each function.
Flask allows method view decoration through a
decorators
attribute:https://flask.palletsprojects.com/en/2.0.x/views/#decorating-views
Implementing this to flask admin would allow a more flexible decoration of the admin views :)
Could something like this work in
Admin
class, withBaseView
having a default class attribute fordecorators
?The text was updated successfully, but these errors were encountered: