Framework Managers¶
One design goal of the base grid class is that it be essentially framework-agnostic. That is, the grid, by itself, should not care if it is being run in Flask, BlazeWeb, or another web app framework. As long as it has a connection to the framework that provides required items with a consistent interface, the grid should interact with the framework through that connection.
Wrapped features available through the manager:
SQLAlchemy connection and queries
Request
Session storage
Flash messages
File export in response
- class webgrid.flask.WebGrid(db=None, jinja_loader=None, args_loaders=None, session_max_hours=None, blueprint_name=None, blueprint_class=None)[source]¶
Grid manager for connecting grids to Flask webapps.
Manager is a Flask extension, and may be bound to an app via
init_app
.Instance should be assigned to the manager attribute of a grid class:
class MyGrid(BaseGrid): manager = WebGrid()
- Args:
db (flask_sqlalchemy.SQLAlchemy, optional): Database instance. Defaults to None. If db is not supplied here, it can be set via
init_db
later.- Class Attributes:
jinja_loader (jinja.Loader): Template loader to use for HTML rendering.
args_loaders (ArgsLoader[]): Iterable of classes to use for loading grid args, in order of priority
session_max_hours (int): Hours to hold a given grid session in storage. Set to None to disable. Default 12.
blueprint_name (string): Identifier to use for the Flask blueprint on this extension. Default “webgrid”. Needs to be unique if multiple managers are initialized as flask extensions.
- blueprint_class¶
alias of
Blueprint