Mixin classes for deleting SQLAlchemy objects from the Database.
Note
The following packages must be installed:
Bases: flask_velox.mixins.sqla.object.SingleObjectMixin, flask_velox.mixins.context.ContextMixin, flask_velox.mixins.template.TemplateMixin
Deletes a single SQLAlchemy object from the Database.
Example
1 2 3 4 5 6 7 8 | form flask.ext.velox.mixins.sqla.delete import DeleteObjectMixin
from yourapp import db
from yourapp.models import MyModel
class DeleteMyModel(DeleteObjectMixin):
template = 'delete.html'
model = MyModel
session = db.sesion
|
Ensure a confirmed flag is required when processing the view, defaults to True
Propery function which returns a bool. If confirm attribute is set to False on the class this will return True else it will only return True if the confirmed query string is present.
Returns: | Ok to delete the object or not |
---|---|
Return type: | bool |
Deletes the object, only if can_delete() returns True.
Flashes a success message to the user.
Adds extra context variables to be used in delete view templates.
See also
Note
Adds the following context variables:
Success callback called after object has been deleted. Override this to customise what happens after an object is delted
Raises: | werkzeug.routing.RequestRedirect – When object is deleted to force a redirect to another View |
---|
Bases: flask_velox.mixins.sqla.delete.DeleteObjectMixin
Mixin provides functionality to delete mutliple objects of the same model.
Override default delete functionality adding the ability to delete multiple objects of the same model but only if can_delete() is True.
Flashes a success message to the user.
Returns a set of objects set for deletion. List of objects is retrived from a HTTP POST list called objects.
Returns: | Set of objects to delete |
---|---|
Return type: | set |
Allowed HTTP Methods
Handle HTTP POST requests rendering a template.
Override context to add objects rather than object to the context.