websauna.system.admin.modeladmin module

Automatic admin and CRUD for SQLAlchemy models.

class websauna.system.admin.modeladmin.ModelAdmin(request)[source]

Bases: websauna.system.crud.sqlalchemy.CRUD

Resource presenting one model in admin interface.

Provide automatized list, show add, edit and delete actions for an SQLAlchemy model which declares admin interface.

class Resource(request, obj)[source]

Bases: websauna.system.crud.sqlalchemy.Resource

get_admin()[source]
get_admin()[source]

Get Admin resource object.

Return type:<InterfaceClass websauna.system.admin.interfaces.IAdmin>
get_model()[source]

Get the SQLAlchemy model instance we are managing.

Returns:SQLAlchemy model instance.
get_title()[source]

Return human-readable title of this resource.

This is viewed in admin breadcrumbs path, etc.

Return type:str
model = None

Model must be set by subclass

title = None

Title used in breadcrumbs, other places

class websauna.system.admin.modeladmin.ModelAdminRoot(request)[source]

Bases: websauna.system.core.traversal.Resource

Admin resource under which all model admins lurk.

To get access this resource:

get_model_admins()[source]

List all registered model admin classes.

Yield:(model_id, IModelAdmin) tuples
get_title()[source]

Return human-readable title of this resource.

This is viewed in admin breadcrumbs path, etc.

items()[source]
Return type:List[Tuple[str, ModelAdmin]]
websauna.system.admin.modeladmin.configure_model_admin(config)[source]

Sets up model -> model admin registry.

websauna.system.admin.modeladmin.model_admin(traverse_id)[source]

Class decorator to mark the class to become part of model admins.

Configure.scan() must be run on this module for the implementation to be picked up.

If there is already an existing model admin with same model, then the existing model admin is overwritten.

Parameters:
  • traverse_id (str) – Under which URL id this model appears in the admin interface. Allowed to contain lowercase letters, dash and digits. This will be available as ModelAdmin.__name__ instance attribute.
  • model_cls – Which model class this admin resource is controlling
Return type:

type