hawat.menu module

This module contains application menu model for Hawat user interface.

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

Bases: hawat.menu.SubmenuEntry

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.

get_entries(**kwargs)[source]

Get list of sub-entries for this menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

List of submenu entries for this entry.

Return type

list

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

Bases: hawat.menu.ViewEntry

Class representing menu entries pointing to application routing endpoints.

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

Bases: hawat.menu.MenuEntry

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_entries(**kwargs)[source]

Get list of sub-entries for this menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

List of submenu entries for this entry.

Return type

list

get_url(**kwargs)[source]

Return URL for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

URL for current menu entry.

Return type

str

is_active(request, **kwargs)[source]

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

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

  • kwargs (dict) – Optional menu entry parameters.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

class hawat.menu.Menu[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_entries(**kwargs)[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.MenuEntry(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_entries(**kwargs)[source]

Get list of sub-entries for this menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

List of submenu entries for this entry.

Return type

list

get_icon(**kwargs)[source]

Return icon for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

Icon for current menu entry.

Return type

str

get_legend(**kwargs)[source]

Return legend for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

Legend for current menu entry.

Return type

str

get_title(**kwargs)[source]

Return title for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

Title for current menu entry.

Return type

str

is_active(request, **kwargs)[source]

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

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

  • kwargs (dict) – Optional menu entry parameters.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

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

Bases: hawat.menu.MenuEntry

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_entries(**kwargs)[source]

Get list of sub-entries for this menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

List of submenu entries for this entry.

Return type

list

is_active(request, **kwargs)[source]

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

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

  • kwargs (dict) – Optional menu entry parameters.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

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

Bases: hawat.menu.MenuEntry

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_entries(**kwargs)[source]

Get list of sub-entries for this menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

List of submenu entries for this entry.

Return type

list

is_active(request, **kwargs)[source]

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

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

  • kwargs (dict) – Optional menu entry parameters.

Returns

True in case menu entry is active, False otherwise.

Return type

bool

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

Bases: hawat.menu.MenuEntry

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_entries(**kwargs)[source]

Get list of sub-entries for this menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

List of submenu entries for this entry.

Return type

list

get_icon(**kwargs)[source]

Return icon for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

Icon for current menu entry.

Return type

str

get_legend(**kwargs)[source]

Return legend for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

Legend for current menu entry.

Return type

str

get_title(**kwargs)[source]

Return title for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

Title for current menu entry.

Return type

str

get_url(**kwargs)[source]

Return URL for current menu entry.

Parameters

kwargs (dict) – Optional menu entry parameters.

Returns

URL for current menu entry.

Return type

str

is_active(request, **kwargs)[source]

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

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

  • kwargs (dict) – Optional menu entry parameters.

Returns

True in case menu entry is active, False otherwise.

Return type

bool