websauna.system.crud package¶
An abstract CRUD implementation based on traversal. The default support for SQLAlchemy and Deform.
-
class
websauna.system.crud.
CRUD
(request)[source]¶ Bases:
websauna.system.core.traversal.Resource
Define create-read-update-delete interface for an model.
We use Pyramid traversing to get automatic ACL permission support for operations. As long given CRUD resource parts define __acl__ attribute, permissions are respected automatically.
URLs are the following:
List: $base/listing
Add: $base/add
Show $base/$id/show
Edit: $base/$id/edit
Delete: $base/$id/delete
-
delete_object
(obj)[source]¶ Delete one item in the CRUD.
Called by delete view if no alternative logic is implemented. :type obj:
object
:param obj: Raw object, e.g. SQLAlchemy instance.
-
abstract
fetch_object
(id)[source]¶ Load object from the database for CRUD path for view/edit/delete.
-
mapper
= <websauna.system.crud.urlmapper.Base64UUIDMapper object>¶ Mapper defines how objects are mapped to URL space. The default mapper assumes models have attribute
uuid
which is base64 encoded to URL. You can change this towebsauna.system.crud.urlmapper.IdMapper
if you instead to want to useid
as a running counter primary column in URLs. This is not recommended in security wise, though.
-
plural_name
= 'items'¶ Helper noun used in the default placeholder texts
-
singular_name
= 'item'¶ Helper noun used in the default placeholder texts
-
title
= '(untitled CRUD)'¶
-
-
class
websauna.system.crud.
Resource
(request, obj)[source]¶ Bases:
websauna.system.core.traversal.Resource
One object in CRUD traversing.
Maps the raw database object under CRUD view/edit/delete control to traverse path.
Presents an underlying model instance mapped to an URL path.
__parent__
attribute points to a CRUD instance.