hawat.view package

This module contains base classes for all hawat application views. They are all based on flask.views.View.

class hawat.view.BaseLoginView[source]

Bases: SimpleView

Base class for login views.

authenticate_user(user)[source]

Authenticate given user.

property dbmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

property dbsession

This property contains the reference to current SQLAlchemy database session.

dispatch_request()[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

fetch(item_id, fetch_by=None)[source]

Perform actual search with given query.

classmethod get_menu_title(**kwargs)[source]

Return menu entry title for the view.

Default implementation returns the return value of hawat.view.BaseView.get_view_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry title for the view.

Return type

str

get_user_login()[source]

Get login of the user that is being authenticated.

classmethod get_view_icon()[source]

Return menu entry icon name for the view. Given name will be used as index to built-in icon registry.

Default implementation generates the icon name by concatenating the prefix module- with module name.

Returns

View icon.

Return type

str

classmethod get_view_name()[source]

Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters [a-z0-9]. It will be used for generating endpoint name for the view.

This method does not have any default implementation and must be overridden by a subclass.

Returns

Name for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Return title for the view, that will be displayed in the title tag of HTML head element and also as the content of page header in h2 tag.

Default implementation returns the return value of hawat.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Title for the view.

Return type

str

is_sign_in = True
class hawat.view.BaseRegisterView[source]

Bases: ItemCreateView

View responsible for registering new user account into application.

do_after_action(item)[source]

Hook method. Will be called after successfull action handling tasks.

do_before_action(item)[source]

Hook method. Will be called before any action handling tasks.

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

static get_message_cancel(**kwargs)[source]

Hook method. Must return text for flash message in case of action cancel. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_duplicate(**kwargs)[source]

Hook method. Must return text for flash message in case of action failure. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_failure(**kwargs)[source]

Hook method. Must return text for flash message in case of action failure. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_success(**kwargs)[source]

Hook method. Must return text for flash message in case of action success. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with hawat.app.hawatBlueprint.register_view_class() method.

Returns

Title for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

classmethod inform_admins(account, form_data)[source]

Send information about new account registration to system admins. Use default locale for email content translations.

classmethod inform_managers(account, form_data)[source]

Send information about new account registration to the group managers. Use manager`s locale for email content translations.

classmethod inform_user(account, form_data)[source]

Send information about new account registration to the user. Use user`s preferred locale for email content translations.

is_sign_up = True
methods: ClassVar[Optional[Collection[str]]] = ['GET', 'POST']

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

class hawat.view.BaseSearchView[source]

Bases: RenderableView, HawatUtils

Base class for search views.

dispatch_request()[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This hook method will be called after successfull search.

This hook method will be called before search attempt.

classmethod get_action_menu()[source]

Get action menu for all items.

classmethod get_breadcrumbs_menu()[source]

Get breadcrumbs menu.

classmethod get_context_action_menu()[source]

Implementation of hawat.view.ItemListView.get_context_action_menu().

static get_query_parameters(form, request_args)[source]

Get query parameters by comparing contents of processed form data and original request arguments. Result of this method can be used for generating modified URLs back to current request. One of the use cases is the result pager/paginator.

classmethod get_quicksearch_by_time()[source]

Get default list of ‘by time’ quickseach items.

static get_search_form(request_args)[source]

Must return instance of flask_wtf.FlaskForm appropriate for searching given type of items.

classmethod get_view_icon()[source]

Implementation of mydojo.base.BaseView.get_view_name().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

search(form_args)[source]

Perform actual search with given query.

class hawat.view.BaseView[source]

Bases: View

Base class for all custom hawat application views.

authentication = False

Similar to the decorators mechanism in Flask pluggable views, you may use this class variable to specify, that the view is protected by authentication. During the process of registering the view into the blueprint in hawat.app.hawatBlueprint.register_view_class() the view will be automatically decorated with flask_login.login_required() decorator.

The advantage of using this in favor of decorators is that the application menu can automatically hide/show items inaccessible to current user.

This is a scalar variable that must contain boolean True or False.

authorization = ()

Similar to the decorators mechanism in Flask pluggable views, you may use this class variable to specify, that the view is protected by authorization. During the process of registering the view into the blueprint in hawat.app.hawatBlueprint.register_view_class() the view will be automatically decorated with given authorization decorators.

The advantage of using this in favor of decorators is that the application menu can automatically hide/show items inaccessible to current user.

This is a list variable that must contain list of desired decorators.

static can_access_endpoint(endpoint, **kwargs)[source]

Check, that the current user can access given endpoint/view.

Parameters
  • endpoint (str) – Application routing endpoint.

  • kwargs (dict) – Optional endpoint parameters.

Returns

True in case user can access the endpoint, False otherwise.

Return type

bool

static get_endpoint_class(endpoint, quiet=False)[source]

Get reference to view class registered to given routing endpoint.

Parameters
  • endpoint (str) – Application routing endpoint.

  • quiet (bool) – Suppress the exception in case given endpoint does not exist.

Returns

Reference to view class.

Return type

class

classmethod get_menu_legend(**kwargs)[source]

Return menu entry legend for the view (menu entry hover tooltip).

Default implementation returns the return value of hawat.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry legend for the view.

Return type

str

classmethod get_menu_title(**kwargs)[source]

Return menu entry title for the view.

Default implementation returns the return value of hawat.view.BaseView.get_view_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Menu entry title for the view.

Return type

str

static get_model(name)[source]

Return reference to class of given model.

Parameters

name (str) – Name of the model.

static get_resource(name)[source]

Return reference to given registered resource.

Parameters

name (str) – Name of the resource.

classmethod get_view_endpoint()[source]

Return name of the routing endpoint for the view within the whole application.

Default implementation generates the endpoint name by concatenating the module name and view name.

Returns

Routing endpoint for the view within the whole application.

Return type

str

classmethod get_view_endpoint_name()[source]

Return unique name for the view endpoint. Name must be unique in the namespace of parent blueprint/module and should contain only characters [a-z0-9]. It will be used for generating endpoint name for the view.

This method does not have any default implementation and must be overridden by a subclass.

Returns

Name for the view.

Return type

str

classmethod get_view_icon()[source]

Return menu entry icon name for the view. Given name will be used as index to built-in icon registry.

Default implementation generates the icon name by concatenating the prefix module- with module name.

Returns

View icon.

Return type

str

classmethod get_view_name()[source]

Return unique name for the view. Name must be unique in the namespace of parent blueprint/module and should contain only characters [a-z0-9]. It will be used for generating endpoint name for the view.

This method does not have any default implementation and must be overridden by a subclass.

Returns

Name for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Return title for the view, that will be displayed in the title tag of HTML head element and also as the content of page header in h2 tag.

Default implementation returns the return value of hawat.view.BaseView.get_menu_title() method by default.

Parameters

kwargs (dict) – Optional parameters.

Returns

Title for the view.

Return type

str

classmethod get_view_url(**kwargs)[source]

Return view URL.

Parameters

kwargs (dict) – Optional parameters.

Returns

URL for the view.

Return type

str

static has_endpoint(endpoint)[source]

Check if given routing endpoint is available within the application.

Parameters

endpoint (str) – Application routing endpoint.

Returns

True in case endpoint exists, False otherwise.

Return type

bool

property logger

Return current application`s logger object.

module_name = None

Name of the parent module/blueprint. Will be set up during the process of registering the view into the blueprint in hawat.app.hawatBlueprint.register_view_class().

module_ref = None

Weak reference to parent module/blueprint of this view.

url_params_unsupported = ()

List of URL parameters, that are not supported by this view and should be removed before generating the URL.

class hawat.view.CustomSearchView[source]

Bases: BaseSearchView

Base class for multi search views.

Perform actual search with given query.

dispatch_request()[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This hook method will be called after successfull search.

class hawat.view.DecoratedView(view_function)[source]

Bases: object

Wrapper class for classical decorated view functions.

get_view_endpoint()[source]

Simple adapter method to enable support of classical decorated views.

get_view_icon()[source]

Simple adapter method to enable support of classical decorated views.

get_view_name()[source]

Simple adapter method to enable support of classical decorated views.

class hawat.view.FileIdView[source]

Bases: BaseView

Base class for indirrect file access views. These views can be used to access and serve files from arbitrary filesystem directories (that are accessible to application process). This can be very usefull for serving files like charts, that are periodically generated into configurable and changeable location. The difference between this view class and FileNameView is, that is this case some kind of identifier is used to access the file and provided class method is responsible for translating this identifier into real file name.

dispatch_request(fileid, filetype)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

classmethod get_directory_path(fileid, filetype)[source]

This method must return absolute path to the directory, that will be used as a base path for serving files. Parameter fileid may be used internally to further customize the base directory, for example when serving some files places into subdirectories based on some part of the file name (for example to reduce total number of files in base directory).

This method does not have any default implementation and must be overridden by a subclass.

Parameters
  • fileid (str) – Identifier of the requested file.

  • filetype (str) – Type of the requested file.

Returns

Absolute path to the directory for serving files.

Return type

str

classmethod get_filename(fileid, filetype)[source]

This method must return actual name of the file based on given identifier and type.

This method does not have any default implementation and must be overridden by a subclass.

Parameters
  • fileid (str) – Identifier of the requested file.

  • filetype (str) – Type of the requested file.

Returns

Translated name of the file.

Return type

str

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

class hawat.view.FileNameView[source]

Bases: BaseView

Base class for direct file access views. These views can be used to access and serve files from arbitrary filesystem directories (that are accessible to application process). This can be very usefull for serving files like charts, that are periodically generated into configurable and changeable location.

dispatch_request(filename)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

classmethod get_directory_path()[source]

Return absolute path to the directory, that will be used as a base path for serving files.

This method does not have any default implementation and must be overridden by a subclass.

Returns

Absolute path to the directory for serving files.

Return type

str

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

classmethod validate_filename(filename)[source]

Validate given file name to prevent user from accessing restricted files.

In default implementation all files pass the validation.

Parameters

filename (str) – Name of the file to be validated/filtered.

Returns

True in case file name is allowed, False otherwise.

Return type

bool

class hawat.view.ItemActionView[source]

Bases: RenderableView

Base class for item action views. These views perform various actions (create/update/delete) with given item class.

classmethod authorize_item_action(**kwargs)[source]

Perform access authorization for current user to particular item.

changelog_log(item, json_state_before='', json_state_after='')[source]

Log item action into changelog. One of the method arguments is permitted to be left out. This enables logging create and delete actions.

Parameters
  • item (hawat.db.MODEL) – Item that is being changed.

  • json_state_before (str) – JSON representation of item state before action.

  • json_state_after (str) – JSON representation of item state after action.

check_action_cancel(form, **kwargs)[source]

Hook method. Check the form for cancel button press and cancel the action.

property dbchlogmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

property dbmodel

This property must be implemented in each subclass to return reference to appropriate model class based on SQLAlchemy declarative base.

property dbsession

This property contains the reference to current SQLAlchemy database session.

do_after_action(item)[source]

Hook method. Will be called after successfull action handling tasks.

do_before_action(item)[source]

Hook method. Will be called before any action handling tasks.

fetch(item_id, fetch_by=None)[source]

Perform actual search with given query.

get_affected_items(item, form)[source]

Return dict of hawat.db.MODEL items affected by the change of the item as keys and their JSON representation before change as value. (e.g. dict of groups which lost a member after a user item was deleted)

Parameters
  • item (hawat.db.MODEL) – Item that is being changed.

  • form (flask_wtf.FlaskForm) – Form representing the change.

static get_message_cancel(**kwargs)[source]

Hook method. Must return text for flash message in case of action cancel. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_failure(**kwargs)[source]

Hook method. Must return text for flash message in case of action failure. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

static get_message_success(**kwargs)[source]

Hook method. Must return text for flash message in case of action success. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

get_url_next()[source]

Hook method. Must return URL for redirection after action success. In most cases there should be call for flask.url_for() function somewhere in this method.

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

classmethod get_view_template()[source]

Implementation of hawat.view.RenderableView.get_view_template().

classmethod get_view_url(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_url().

handle_error(**kwargs)[source]

Handle and log the error, rollback all database changes and show the failure message to user.

class hawat.view.ItemChangeView[source]

Bases: ItemActionView

Base class for single item change views, that are doing some simple modification of item attribute, like enable/disable item, etc.

classmethod change_item(**kwargs)[source]

Hook method: Change given item in any desired way.

Parameters

item – Item to be changed/modified.

dispatch_request(item_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This method will attempt to validate the submitted form, then perform arbitrary mangling action with the item and submit the changes to the database.

classmethod validate_item_change(**kwargs)[source]

Perform validation of particular change to given item.

class hawat.view.ItemCreateForView[source]

Bases: ItemActionView

Base class for item createfor action views. These views differ a little bit from create action views. They are used to create new items within database, but only for particular defined parent item. One example use case is creating network records for particular abuse group.

static add_parent_to_item(item, parent)[source]

Hook method. Use given parent object for given item object. The actual operation to realize this relationship is highly dependent on current circumstance. It is up to the developer to perform correct set of actions to implement parent - child relationship for particular object types.

property dbmodel_par

Hook property. This property must be implemented in each subclass to return reference to appropriate model class for parent objects and that is based on SQLAlchemy declarative base.

property dbquery_par

This property contains the reference to SQLAlchemy query object appropriate for particular dbmodel_par property.

dispatch_request(parent_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This method will attempt to validate the submitted form and create new instance of appropriate item from form data and finally store the item into the database.

classmethod get_breadcrumbs_menu()[source]
get_item()[source]

Hook method. Must return instance for given item class.

static get_item_form(item)[source]

Hook method. Must return instance of flask_wtf.FlaskForm appropriate for given item class.

static get_message_duplicate(**kwargs)[source]

Hook method. Must return text for flash message in case of action failure. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with hawat.app.hawatBlueprint.register_view_class() method.

Returns

Title for the view.

Return type

str

classmethod get_view_url(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_url().

class hawat.view.ItemCreateView[source]

Bases: ItemActionView

Base class for item create action views. These views create new items in database.

dispatch_request()[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This method will attempt to validate the submitted form and create new instance of appropriate item from form data and finally store the item into the database.

classmethod get_breadcrumbs_menu()[source]
get_item()[source]

Hook method. Must return instance for given item class.

static get_item_form(item)[source]

Hook method. Must return instance of flask_wtf.FlaskForm appropriate for given item class.

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

static get_message_duplicate(**kwargs)[source]

Hook method. Must return text for flash message in case of action failure. The text may contain HTML characters and will be passed to flask.Markup before being used, so to certain extend you may emphasize and customize the output.

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with hawat.app.hawatBlueprint.register_view_class() method.

Returns

Title for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

classmethod get_view_url(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_url().

class hawat.view.ItemDeleteView[source]

Bases: ItemActionView

Base class for item delete action views. These views delete existing items from database.

dispatch_request(item_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This method will attempt to validate the submitted form and delete the instance of appropriate item from database in case user agreed to the item removal action.

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

class hawat.view.ItemDisableView[source]

Bases: ItemChangeView

Base class for item disabling views.

classmethod change_item(**kwargs)[source]

Implementation of hawat.view.ItemChangeView.change_item().

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

classmethod validate_item_change(**kwargs)[source]

Implementation of hawat.view.ItemChangeView.validate_item_change().

class hawat.view.ItemEnableView[source]

Bases: ItemChangeView

Base class for item enabling views.

classmethod change_item(**kwargs)[source]

Implementation of hawat.view.ItemChangeView.change_item().

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

classmethod validate_item_change(**kwargs)[source]

Implementation of hawat.view.ItemChangeView.validate_item_change().

class hawat.view.ItemListView[source]

Bases: RenderableView

Base class for item list views. These views provide quick and simple access to lists of all objects.

dispatch_request()[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

List of all items will be retrieved from database and injected into template to be displayed to the user.

classmethod get_action_menu()[source]

Get action menu for all listed items.

classmethod get_breadcrumbs_menu()[source]

Get breadcrumbs menu.

classmethod get_context_action_menu()[source]

Get context action menu for particular single item.

static get_query_parameters(form, request_args)[source]

Get query parameters by comparing contents of processed form data and original request arguments. Result of this method can be used for generating modified URLs back to current request. One of the use cases is the result pager/paginator.

static get_search_form(request_args)[source]

Must return instance of flask_wtf.FlaskForm appropriate for searching given type of items.

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

search(form_args)[source]

Perform actual search with given form arguments.

class hawat.view.ItemObjectRelationView[source]

Bases: ItemChangeView

Base class for item object relation action views.

property dbmodel_other

Hook property. This property must be implemented in each subclass to return reference to appropriate model class for other objects and that is based on SQLAlchemy declarative base.

property dbquery_other

This property contains the reference to SQLAlchemy query object appropriate for particular dbmodel_other property.

dispatch_request(item_id, other_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This method will attempt to validate the submitted form and create new instance of appropriate item from form data and finally store the item into the database.

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with hawat.app.hawatBlueprint.register_view_class() method.

Returns

Title for the view.

Return type

str

classmethod get_view_url(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_url().

class hawat.view.ItemShowView[source]

Bases: RenderableView

Base class for item show views. These views expect unique item identifier as parameter and are supposed to display specific information about single item.

classmethod authorize_item_action(**kwargs)[source]

Perform access authorization for current user to particular item.

dispatch_request(item_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

Single item with given unique identifier will be retrieved from database and injected into template to be displayed to the user.

fetch(item_id)[source]

Fetch item with given ID.

classmethod get_action_menu()[source]

Get action menu for particular item.

classmethod get_breadcrumbs_menu()[source]

Get breadcrumbs menu.

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

classmethod get_view_icon()[source]

Implementation of hawat.view.BaseView.get_view_icon().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

classmethod get_view_url(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_url().

class hawat.view.ItemUpdateView[source]

Bases: ItemActionView

Base class for item update action views. These views update existing items in database.

dispatch_request(item_id)[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.

This method will attempt to validate the submitted form and update the instance of appropriate item from form data and finally store the item back into the database.

get_affected_items(item, form)[source]

Return dict of hawat.db.MODEL items affected by the update of the item as keys and their JSON representation before update as value. (e.g. dict of groups which lost a member after a user item was updated) Overrides get_affected_items(self, item, form) in ItemActionView.

Parameters
  • item (hawat.db.MODEL) – Item that is being changed.

  • form (flask_wtf.FlaskForm) – Form representing the change.

classmethod get_breadcrumbs_menu()[source]
static get_item_form(item)[source]

Hook method. Must return instance of flask_wtf.FlaskForm appropriate for given item class.

classmethod get_menu_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_menu_title().

classmethod get_view_name()[source]

Implementation of hawat.view.BaseView.get_view_name().

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with hawat.app.hawatBlueprint.register_view_class() method.

Returns

Title for the view.

Return type

str

classmethod get_view_title(**kwargs)[source]

Implementation of hawat.view.BaseView.get_view_title().

class hawat.view.RenderableView[source]

Bases: BaseView

Base class for all views, that are rendering content based on Jinja2 templates or returning JSON/XML data.

static abort(status_code, message=None)[source]

Abort request processing with HTTP status code.

do_before_response(**kwargs)[source]

This method will be called just before generating the response. By providing some meaningfull implementation you can use it for some simple item and response context mangling tasks.

Parameters

kwargs – Custom additional arguments.

flash(message, level='info')[source]

Flash information to the user.

generate_response()[source]

Generate the appropriate response from given response context.

Parameters

response_context (dict) – Response context as a dictionary

classmethod get_view_template()[source]

Return Jinja2 template file that should be used for rendering the view content. This default implementation works only in case the view class was properly registered into the parent blueprint/module with hawat.app.hawatBlueprint.register_view_class() method.

Returns

Jinja2 template file to use to render the view.

Return type

str

mark_time(ident, threshold, tag='default', label='Time mark', log=False)[source]

Mark current time with given identifier and label for further analysis. This method can be usefull for measuring durations of various operations.

redirect(default_url=None, exclude_url=None)[source]

Redirect user to different location.

class hawat.view.SimpleView[source]

Bases: RenderableView

Base class for simple views. These are the most, well, simple views, that are rendering single template file or directly returning some JSON/XML data without any user parameters.

In most use cases, it should be enough to just enhance the default implementation of hawat.view.RenderableView.get_response_context() to inject some additional variables into the template.

dispatch_request()[source]

Mandatory interface required by the flask.views.View.dispatch_request(). Will be called by the Flask framework to service the request.