Operations

Operations are a views that perform simple no-input actions against model instances.

Delete

Deletes the instance.

class flask_kibble.Delete
recursive = False

Delete the object and its descendants recursively?

Custom Operations

Custom operations can be defined by subclassing Operation and implementing, at the very least, run.

class flask_kibble.Operation
exception Failure

To be raised when an operation fails.

Operation.form

The form used when requiring confirmation. By default this is an empty csrf-protected form

alias of BaseOperationForm

Operation.get_form_instance(instance=None)

Returns an instance of the form for the view.

Parameters:instance – The instance to edit or None.
Operation.get_message(instance, result)

Upon success or failure, this will be called to determine which message to flash to the user.

Parameters:
  • instance – The instance operated on.
  • result – The return value of self.run() or an Failure exception.
Returns:

The message to flash to the user.

Operation.get_redirect(instance, result)

Upon success or failure, this will be called to determine where to redirect the user to.

Parameters:
  • instance – The instance operated on.
  • result – The return value of self.run() or an Operation.Failure exception.
Returns:

The url to redirect to on success.

Operation.past_tense = None

The past tense verb of the action. Used to display default messages e.g. delete/deleted.

Operation.require_confirmation = True

If true, the user will be taken to an intermediate confirmation page otherwise, the operation will be performed immediately.

Operation.run(instance, form=None)

Perform the operation on the given instance.

If the operation fails, this function should raise a Operation.Failure. All other exception types will result in a HTTP-500 error.

Parameters:instance – The instance.
Returns:Any value. If the response is a flask.Response, it will be returned to the user.
Raises:Failure to signify the operation failed.