Changes between Version 12 and Version 13 of AuditTrail


Ignore:
Timestamp:
08/09/2008 01:25:22 PM (7 years ago)
Author:
larrik
Comment:

I updated the code to handle the 1.0 signal refactoring. I left the old code in there, commented out, for easy swapping between Signal versions. I'm very new to Django, though, so I think someone should else should look at this before it gets moved to any production environments. Sorry if I handled this poorly, I'm just trying to help.

Legend:

Unmodified
Added
Removed
Modified
  • AuditTrail

    v12 v13  
    11= Automating an audit trail =
    22
    3 As raised in [http://groups.google.com/group/django-developers/browse_thread/thread/ab7649e4abd4e589 a recent discussion on django-developers], this code is one solution for creating an audit trail for a given model. '''This is working in multiple production sites, but is still incomplete.  See [#Caveats Caveats] below for more information.''' The code below requires an SVN checkout as of r7790 or later.
     3As raised in [http://groups.google.com/group/django-developers/browse_thread/thread/ab7649e4abd4e589 a recent discussion on django-developers], this code is one solution for creating an audit trail for a given model. '''This is working in multiple production sites, but is still incomplete.  See [#Caveats Caveats] below for more information.''' The code below requires an SVN checkout as of r8223 or later.
    44
    55== Usage ==
     
    187187                    kwargs[field_arr[0]] = _audit_track(instance, field_arr)
    188188                model._default_manager.create(**kwargs)
    189             dispatcher.connect(_audit, signal=models.signals.post_save, sender=cls, weak=False)
     189            ## Uncomment this line for pre r8223 Django builds
     190            #dispatcher.connect(_audit, signal=models.signals.post_save, sender=cls, weak=False)
     191            ## Comment this line for pre r8223 Django builds
     192            models.signals.post_save.connect(_audit, sender=cls, weak=False)
    190193
    191194            if self.opts['audit_deletes']:
     
    200203                        kwargs[field_arr[0]] = _audit_track(instance, field_arr)
    201204                    model._default_manager.create(**kwargs)
    202                 dispatcher.connect(_audit_delete, signal=models.signals.pre_delete, sender=cls, weak=False)
    203 
    204         dispatcher.connect(_contribute, signal=models.signals.class_prepared, sender=cls, weak=False)
     205                ## Uncomment this line for pre r8223 Django builds
     206                #dispatcher.connect(_audit_delete, signal=models.signals.pre_delete, sender=cls, weak=False)
     207                ## Comment this line for pre r8223 Django builds
     208                models.signals.pre_delete.connect(_audit_delete, sender=cls, weak=False)
     209       
     210        ## Uncomment this line for pre r8223 Django builds
     211        #dispatcher.connect(_contribute, signal=models.signals.class_prepared, sender=cls, weak=False)
     212        ## Comment this line for pre r8223 Django builds
     213        models.signals.class_prepared.connect(_contribute, sender=cls, weak=False)
    205214
    206215class AuditTrailDescriptor(object):
Back to Top