hawat.blueprints.dbstatus package

This pluggable module provides access to database status information. The following information is provided:

  • general statistics of event database:

    • general statistics of events table

      • estimated number of records

      • table size, index size, tablespace size and total size

      • oldest and youngest record timestamp, record timespan

    • general statistics of event_thresholds table

      • estimated number of records

      • table size, index size, tablespace size and total size

      • oldest and youngest record timestamp, record timespan

    • general statistics of thresholds table

      • estimated number of records

      • table size, index size, tablespace size and total size

      • oldest and youngest record timestamp, record timespan

  • PostgreSQL configurations

Provided endpoints

/dbstatus/view

Page providing read-only access various database status characteristics.

Authentication: login required Authorization: admin role only Methods: GET

class hawat.blueprints.dbstatus.AbstractQueryStopView[source]

Bases: PsycopgMixin, RenderableView

Application view providing ability to stop given query.

authentication = True

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.

classmethod authorize_item_action(**kwargs)[source]
check_action_cancel(form, **kwargs)[source]

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

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.

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_message_cancel(**kwargs)[source]
static get_message_failure(**kwargs)[source]
static get_message_success(**kwargs)[source]
get_url_next()[source]
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_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

methods: t.ClassVar[t.Optional[t.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.blueprints.dbstatus.ApiQueryStopView[source]

Bases: AJAXMixin, AbstractQueryStopView

Application view providing ability to stop given query.

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

hawat.blueprints.dbstatus.BLUEPRINT_NAME = 'dbstatus'

Name of the blueprint as module global constant.

class hawat.blueprints.dbstatus.DashboardView[source]

Bases: HTMLMixin, SQLAlchemyMixin, SimpleView

View responsible for presenting database dashboard.

authentication = True

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 = [<Permission needs={Need(method='role', value='admin'), Need(method='role', value='maintainer')} excludes=set()>]

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.

do_before_response(**kwargs)[source]

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

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

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_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

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

class hawat.blueprints.dbstatus.DatabaseStatusBlueprint(name, import_name, **kwargs)[source]

Bases: HawatBlueprint

Pluggable module - database status overview (dbstatus).

classmethod get_module_title()[source]

Get human readable name for this blueprint/module.

Returns

Name (short summary) of the blueprint/module.

Return type

str

register_app(app)[source]

Hook method: Custom callback, which will be called from hawat.app.Hawat.register_blueprint() method and which can perform additional tweaking of Hawat application object.

Parameters

app (hawat.app.Hawat) – Application object.

class hawat.blueprints.dbstatus.MyQueriesView[source]

Bases: HTMLMixin, PsycopgMixin, SimpleView

Application view providing access status information of given single query.

authentication = True

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.

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.

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

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

class hawat.blueprints.dbstatus.QueryStatusView[source]

Bases: AJAXMixin, PsycopgMixin, RenderableView

Application view providing access status information of given single query.

authentication = True

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.

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.

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.

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

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

class hawat.blueprints.dbstatus.QueryStopView[source]

Bases: HTMLMixin, AbstractQueryStopView

Application view providing ability to stop given query.

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_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

class hawat.blueprints.dbstatus.ViewView[source]

Bases: HTMLMixin, PsycopgMixin, SimpleView

Application view providing access event database status information.

authentication = True

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 = [<Permission needs={Need(method='role', value='admin')} excludes=set()>]

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.

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.

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

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

hawat.blueprints.dbstatus.get_blueprint()[source]

Mandatory interface for hawat.Hawat and factory function. This function must return a valid instance of hawat.app.HawatBlueprint or flask.Blueprint.