<s> from django . db import models <EOL> from django . db . models . signals import post_save <EOL> from django . dispatch import Signal <EOL> class SignalFieldMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def value_from_object ( self , obj ) : <EOL> if not hasattr ( obj , "<STR_LIT>" ) : <EOL> obj . _state = { } <EOL> obj . _state [ self . name ] = obj . __dict__ . get ( self . name ) <EOL> return super ( SignalFieldMixin , self ) . value_from_object ( obj ) <EOL> def contribute_to_class ( self , cls , name ) : <EOL> super ( SignalFieldMixin , self ) . contribute_to_class ( cls , name ) <EOL> post_save . connect ( self . updated , sender = cls ) <EOL> def updated ( self , instance , force = False , * args , ** kwargs ) : <EOL> if hasattr ( instance , "<STR_LIT>" ) : <EOL> fields_updated . send ( sender = instance , state = instance . _state ) <EOL> del instance . _state <EOL> class SignalSlugField ( SignalFieldMixin , models . SlugField ) : <EOL> pass <EOL> fields_updated = Signal ( providing_args = [ "<STR_LIT:state>" ] ) </s>
