#NEWLINE# @ receiver ( post_save , sender = Task ) #NEWLINE# def call_hook( sender , instance , **kwargs ) : #NEWLINE# #INDENT# if kwargs . hook : #NEWLINE# #INDENT# f = instance . hook #NEWLINE# if ( not callable ( f ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( module , func ) = f . rsplit ( '.' , 1 ) #NEWLINE# m = importlib . import_module ( module ) #NEWLINE# f = getattr ( m , func ) #NEWLINE# #UNINDENT# except ( ValueError , ImportError , AttributeError ) : #NEWLINE# #INDENT# logger . error ( _ ( "malformed return hook '{}' for [{}]" ) . format ( instance . hook , instance . name ) ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# f ( instance ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logger . error ( _ ( 'return hook {} failed on [{}] because {}' ) . format ( instance . hook , instance . name , e ) )