[Catalyst] Audit logs: model or controller?

Matt S Trout dbix-class at trout.me.uk
Mon Sep 17 15:15:36 GMT 2007

On Mon, Sep 17, 2007 at 12:55:52PM +0100, Ton Voon wrote:
> Hi!
> I have a requirement for adding an audit log of certain actions  
> (creating an object, editing the object, etc) to our web app. In my  
> mind, it is best to do this at the model, so it is consistent  
> regardless of the method of access.

The DBIx-Class-Journal stuff in trunk is pretty good for this, needs more
testing before we ship it but basically there.

> However, one key bit of information I'd like to save is the user at  
> the web app level. But this is not passed to the model. What would be  
> a good way of having that information passed to the model (I was  
> thinking of setting an environment variable at the start of a request  
> and then removing it at the end)? Or is it best to have audit logs at  
> the controller?

I tend to use DBIx::Class::Schema::RestrictWithObject
+ Catalyst::Component::InstancePerContext a lot and use the current user as
the restricting object, which mostly makes this go away.

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

More information about the Catalyst mailing list