diff --git a/lib/hawat/base.py b/lib/hawat/base.py index 87ee99c1fa052ab3f85463bf204809bc2c55357e..be579b44a486a197e710f7ee81f095cc82abfd6c 100644 --- a/lib/hawat/base.py +++ b/lib/hawat/base.py @@ -29,6 +29,7 @@ Module contents * :py:class:`SQLAlchemyMixin` * :py:class:`PsycopgMixin` +* :py:class:`DecoratedView` * :py:class:`BaseView` * :py:class:`FileNameView` @@ -972,6 +973,26 @@ class PsycopgMixin: #------------------------------------------------------------------------------- +class DecoratedView: + """ + Wrapper class for classical decorated view functions. + """ + def __init__(self, view_function): + self.view_function = view_function + + def get_view_name(self): + """Simple adapter method to enable support of classical decorated views.""" + return self.view_function.__name__ + + def get_view_endpoint(self): + """Simple adapter method to enable support of classical decorated views.""" + return self.get_view_name() + + def get_view_icon(self): + """Simple adapter method to enable support of classical decorated views.""" + return 'view-{}'.format(self.get_view_name()) + + class BaseView(flask.views.View): """ Base class for all custom Hawat application views.