Thanks! Looks interesting.

I was thinking of creating a ActionLog-like model and storing the log in 
db instead of a log file.


On Mon, 05 Mar 2007 18:41:30 -0800, Rubic wrote:

> My solution is this:  I've ripped out some stuff from the old admin code
> and written AppLogModel with three methods:
> 
>     def add(self, request):
>     def remove(self, request):
>     def update(self, request):
> 
> The add/update methods call save() and remove calls delete().  Each
> method invokes a log action acting on AppLogger[*]
> 
> AppLogModel is a mixin subclassed in my application models, e.g.:
> 
> class TreatmentOrders(AppLogModel, models.Model):
>     class Admin:
>         pass
> 
> My views call add/update rather than save and pass along 'request' to
> log the user actions.
> 
> There's a minor defect with tracking changes by field.  But rather than
> fix it, I'll just wait for Adrian to finish newforms-admin and rip off
> his code.  ;-)
> 
> I'll consider posting this to djangosnippets.org later (preferably after
> newforms-admin is completed), but this might give you one possible
> avenue to pursue.
> 
> If there's any interest from the Django People(tm) in generalizing this
> approach for mainstream apps, they know where to find me.  ;-)
> 
> --
> [*] Incomplete class description below:
> 
> class AppLogger(models.Model):
>     action_time = models.DateTimeField(_('action time'),
> auto_now=True)
>     user = models.ForeignKey(User)
>     content_type = models.ForeignKey(ContentType, blank=True,
> null=True)
>     object_id = models.TextField(_('object id'), blank=True,
> null=True)
>     object_repr = models.CharField(_('object repr'), maxlength=200)
>     action_flag = models.PositiveSmallIntegerField(_('action flag'))
>     change_message = models.TextField(_('change message'), blank=True)
>     objects = AppLoggerManager()
>     class Meta:
>         verbose_name = _('log entry')
>         verbose_name_plural = _('log entries') db_table = 'applog'
>         ordering = ('-action_time',)
>     class Admin:
>         pass
> 
> --
> Jeff Bauer
> Rubicon, Inc.
> 
> 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to