#NEWLINE# def permissions_delete_override( permittee_kw , model_func , delete_perm ) : #NEWLINE# #INDENT# 'Get a delete function that can be used to enforce\n    delete permissions.\n    \n    For example::\n    \n        class ModelX(models.Model):\n            ...\n            delete = permissions_delete_override(\n                "user", lambda: ModelX, "can_delete")\n            \n    @param permittee_kw: the keyword used to store the permittee in\n        threadlocals\n    @type permittee_kw: C{str}.\n    @param model_func: A callable that returns the class.\n    @type model_func: C{Model} subclass\n    @param delete_perm: the name of the delete permission for the instance.\n    @type delete_perm: C{str}\n    ' #NEWLINE# def delete( self , * args , **kwargs ) : #NEWLINE# #INDENT# '\n        Override the default delete method to enforce permissions.\n        ' #NEWLINE# must_have_permission ( permittee_kw , self , delete_perm ) #NEWLINE# ObjectPermission . objects . filter_from_instance ( self ) . delete ( ) #NEWLINE# super ( model_func ( ) , self ) . delete ( * args , ** kwargs ) #NEWLINE# #UNINDENT# return delete