[Catalyst] Automatic passing of objects to DBIx::Class

Ido Perlmuter ido at ido50.net
Sun Feb 28 06:58:37 GMT 2010

Hi everyone.

I've been racking my brain trying to find a way to automatically pass an
object, for the matter the Catalyst::Request object, to DBIx::Class methods.
I cannot and will not pass it myself every time I call a method in my
schema. While I do believe the model and the app should be completely
separated, further information must flow between the two.

For example, I need to setup an administrative usage log for my app.
Whenever a user with proper privileges invokes a schema method that creates,
edits or deletes information from the database, I want that action to be
automatically recorded in the usage log, with details such as the user ID
and the user IP. I'm facing two difficulties: on one hand I believe this
should be automatically done by the schema (so recording into the usage log
will not be made from the app, but from the schema), but that means I need
to pass the
context object (or the Request object) to every schema method I invoke; on
the other hand, if I let the app handle recording into the usage log, my
schema loses power. What if I want to write an API to my program in several
programming languages, should they do the same too?

So for a while now I've been trying to find a way to automatically pass
objects to the schema. Maybe if DBIx::Class was Moose-based I would have
already found one using method modifiers.

Any thoughts will be appreciated.

Ido Perlmuter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100228/8a958=

More information about the Catalyst mailing list