hawat.menu module

This module contains application menu model for Hawat user interface.

class hawat.menu.HawatDbSubmenuMenuEntry(ident, **kwargs)[source]

Bases: hawat.menu.HawatMenuEntry

Class for entries representing whole submenu trees whose contents are fetched on demand from database.

add_entry(ident, subentry)[source]

Add new entry into the submenu of this entry.

Parameters

ident (str) – Unique identifier of the subentry within the submenu.

entries

Dynamical property fetching current set of submenu entries from database.

get_menu(item=None)[source]

Get list of submenu entries for this entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

List of submenu entries for this entry.

Return type

list

is_active(request, item=None)[source]

Check, if this menu entry is active thanks to the given request.

Parameters
  • request (flask.Request) – Current request object.

  • item – Optional item for which the menu entry should be parametrized.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

class hawat.menu.HawatEndpointMenuEntry(ident, endpoint, **kwargs)[source]

Bases: hawat.menu.HawatViewMenuEntry

Class representing menu entries pointing to application routing endpoints.

class hawat.menu.HawatLinkMenuEntry(ident, **kwargs)[source]

Bases: hawat.menu.HawatMenuEntry

Class representing menu entries pointing to application views.

add_entry(ident, subentry)[source]

Add new entry into the submenu of this entry.

Parameters

ident (str) – Unique identifier of the subentry within the submenu.

get_menu(item=None)[source]

Get list of submenu entries for this entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

List of submenu entries for this entry.

Return type

list

get_url(item=None)[source]

Return URL for current entry.

Parameters

item – Optional item for which the menu should be parametrized.

Returns

URL for current menu entry.

Return type

str

is_active(request, item=None)[source]

Check, if this menu entry is active thanks to the given request.

Parameters
  • request (flask.Request) – Current request object.

  • item – Optional item for which the menu entry should be parametrized.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

class hawat.menu.HawatMenu[source]

Bases: object

Class for application menu.

add_entry(entry_type, ident, **kwargs)[source]

Add new entry into the menu.

Parameters
  • entry_type (str) – Type/class of the menu entry as string, object of the correct class will be created.

  • ident (str) – Unique identifier of the entry within the menu.

  • kwargs (dict) – Additional arguments, that will be passed to the constructor of the appropriate entry class.

get_menu(item=None)[source]

Get list of entries for this menu.

Parameters

item – Optional item for which the menu should be parametrized.

Returns

List of entries for this menu.

Return type

list

class hawat.menu.HawatMenuEntry(ident, **kwargs)[source]

Bases: object

Base class for all menu entries.

add_entry(ident, subentry)[source]

Add new entry into the submenu of this entry.

Parameters

ident (str) – Unique identifier of the subentry within the submenu.

get_icon(item=None)[source]

Return menu icon for current entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

Icon for current menu entry.

Return type

str

get_legend(item=None)[source]

Return menu legend for current entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

Legend for current menu entry.

Return type

str

get_menu(item=None)[source]

Get list of submenu entries for this entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

List of submenu entries for this entry.

Return type

list

get_title(item=None)[source]

Return menu title for current entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

Title for current menu entry.

Return type

str

is_active(request, item=None)[source]

Check, if this menu entry is active thanks to the given request.

Parameters
  • request (flask.Request) – Current request object.

  • item – Optional item for which the menu entry should be parametrized.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

class hawat.menu.HawatSubmenuMenuEntry(ident, **kwargs)[source]

Bases: hawat.menu.HawatMenuEntry

Class for entries representing whole submenu trees.

add_entry(ident, subentry)[source]

Add new entry into the submenu of this entry.

Parameters

ident (str) – Unique identifier of the subentry within the submenu.

get_menu(item=None)[source]

Get list of submenu entries for this entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

List of submenu entries for this entry.

Return type

list

is_active(request, item=None)[source]

Check, if this menu entry is active thanks to the given request.

Parameters
  • request (flask.Request) – Current request object.

  • item – Optional item for which the menu entry should be parametrized.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

class hawat.menu.HawatTestMenuEntry(ident, **kwargs)[source]

Bases: hawat.menu.HawatMenuEntry

Class for menu entries for testing and demonstration purposes.

add_entry(ident, subentry)[source]

Add new entry into the submenu of this entry.

Parameters

ident (str) – Unique identifier of the subentry within the submenu.

get_menu(item=None)[source]

Get list of submenu entries for this entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

List of submenu entries for this entry.

Return type

list

is_active(request, item=None)[source]

Check, if this menu entry is active thanks to the given request.

Parameters
  • request (flask.Request) – Current request object.

  • item – Optional item for which the menu entry should be parametrized.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

class hawat.menu.HawatViewMenuEntry(ident, **kwargs)[source]

Bases: hawat.menu.HawatMenuEntry

Class representing menu entries pointing to application views.

add_entry(ident, subentry)[source]

Add new entry into the submenu of this entry.

Parameters

ident (str) – Unique identifier of the subentry within the submenu.

authentication

Property containing authentication information for current entry.

Returns

Authentication information for current menu entry.

Return type

str

authorization

Property containing authorization information for current entry.

Returns

Authorization information for current menu entry.

Return type

str

endpoint

Property containing routing endpoint for current entry.

Returns

Routing endpoint for current menu entry.

Return type

str

get_icon(item=None)[source]

Return menu icon for current entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

Icon for current menu entry.

Return type

str

get_legend(item=None)[source]

Return menu legend for current entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

Legend for current menu entry.

Return type

str

get_menu(item=None)[source]

Get list of submenu entries for this entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

List of submenu entries for this entry.

Return type

list

get_title(item=None)[source]

Return menu title for current entry.

Parameters

item – Optional item for which the menu entry should be parametrized.

Returns

Title for current menu entry.

Return type

str

get_url(item=None)[source]

Return URL for current entry.

Parameters

item – Optional item for which the menu should be parametrized.

Returns

URL for current menu entry.

Return type

str

is_active(request, item=None)[source]

Check, if this menu entry is active thanks to the given request.

Parameters
  • request (flask.Request) – Current request object.

  • item – Optional item for which the menu entry should be parametrized.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

pick_item(item=None)[source]

Pick item to be used for current menu entry parametrization.