Code documentation


class deletion_side_effects.deletion_side_effects.BaseDeletionSideEffects

Provides the interface for a user to make a deletion side effects class. The user must define the following:

  1. A deleted_obj_class variable. This variable denotes the class of the object being deleted.
  2. A ‘get_side_effects` method. This method is passed a list of objects of deleted_obj_class type that are candidates for deletion. The method returns a tuple of objects that are affected by deletion of the objects for deletion (i.e the side effect objects) and a list of objects that will be cascade deleted if the candidate objects are deleted.
  3. A get_side_effect_message method. This method is passed all of the side effect objects from gathering side effects with the class. The method is responsible for returning a human-readable string of he side effects.

Given a list of objects that have this side effect associated with them, return a human readable message about the side effect.


Returns a tuple. The first part of the tuple is list of objects that have side effects associated with them. The second part of the tuple is a list of other objects that will be deleted as a result of the passed objects being deleted. Side effects of other deleted models will be populated when gather_deletion_side_effects is called.

deletion_side_effects.deletion_side_effects.gather_deletion_side_effects(obj_class, objs)

Given an object, gather the side effects of deleting it. The return value is a list of dictionaries, each of which contain the following keys:

  1. msg - This key contains a human-readable message of the side effect.
  2. side_effect_objs: This key contains a list of ever object related to this side effect and the message.

Registers deletion side effect handler classes. The class must inherit BaseDeletionSideEffects and define a deleted_obj_class variable.