Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a decorators attribute to FlaskView #21

Merged
merged 1 commit into from Apr 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions flask_classy.py
Expand Up @@ -51,6 +51,9 @@ class FlaskView(object):

__metaclass__ = _FlaskViewMeta

#: A list of decorators to be applied to all view of this class
decorators = []

@classmethod
def register(cls, app, route_base=None, subdomain=None):
"""Registers a FlaskView class for use with a specific instance of a
Expand Down Expand Up @@ -151,6 +154,10 @@ def make_proxy_method(cls, name):
i = cls()
view = getattr(i, name)

if cls.decorators:
for decorator in cls.decorators:
view = decorator(view)

@functools.wraps(view)
def proxy(*args, **kwargs):
if hasattr(i, "before_request"):
Expand Down