API

sqlalchemy_nav.Base

class sqlalchemy_nav.Base(template, label=None, href=None, *args, **kwargs) [source]

All SQLAlchemy-Nav mixins inherit from this base.

Parameters: template : str

Relative path to the html template file. Users should not pass this argument; it is passed automatically by mixins.

label : str

Label (text) of the first <a> tag.

href : str

Hyperref of the first <a> tag.

Attributes: id : int

Model identifier.

index : int

Order of the model in its parent's list. e.g. the 0th Navitem in a Navbar has an index of 0.

body : sqlalchemy_mutablesoup.MutableSoup

The body of the object. This is converted to html when the object is rendered.

a : bs4.Tag

First <a> html tag in body.

label : str

Text of a. Set from the label parameter.

href : str

Hyperref of a. Set from the href parameter.

Methods

is_active(self) [source]

Returns: is_active : bool

Indicates that the object's href is active.

render(self, body=None) [source]

Prepares a bs4.BeautifulSoup object for rendering into html.

Parameters: body : sqlalchemy_mutablesoup.MutableSoup or None, default=None

Object to render. If None, a copy of self.body is used.

Returns: body : sqlalchemy_mutablesoup.MutableSoup

Prepared for rendering into html.

sqlalchemy_nav.NavbarMixin

class sqlalchemy_nav.NavbarMixin(name=None, *args, **kwargs) [source]

Navigation bar mixin.

Parameters: name : str

Name of the navigation bar. This facilitates finding the navigation bar when querying the database.

*args, **kwargs :

Additional arguments and keyword arguments are passed to Base.__init__.

Attributes: name : str

Set from the name parameter.

navitems : sqlalchemy.ext.orderinglist.OrderingList

List of Navitem objects ordered by index.

sqlalchemy_nav.NavitemMixin

class sqlalchemy_nav.NavitemMixin(navbar=None, dropdown=False, *args, **kwargs) [source]

Navigation item mixin.

Parameters: navbar : sqlalchemy_nav.NavbarMixin or None, default=None

Navigation bar with which this navigation item is associated.

dropdown : bool, default=False

Indicates that this navitem will contain dropdown items.

*args, **kwargs :

Additional arguments and keyword arguments are passed to Base.__init__.

Attributes: navbar : sqlalchemy_nav.NavbarMixin or None

Set from the navbar parameter.

dropdownitems : sqlalchemy.ext.orderinglist.OrderingList

List of Dropdownitem objects ordered by index.

sqlalchemy_nav.DropdownitemMixin

class sqlalchemy_nav.DropdownitemMixin(navitem=None, *args, **kwargs) [source]

Dropdown item mixin.

Parameters: navitem : sqlalchemy_nav.NavitemMixin or None, default=None

Navigation item with which this dropdown item is associated.

*args, **kwargs :

Additional arguments and keyword arguments are passed to Base.__init__.

Attributes: navitem : sqlalchemy_nav.NavitemMixin or None

Set from the navitem parameter.