[Dbix-class] Protecting records from update / overloading
Matt S Trout
dbix-class at trout.me.uk
Fri Oct 5 19:08:12 GMT 2007
On Thu, Oct 04, 2007 at 11:06:28PM -0500, Mitchell Jackson wrote:
> Friends,
>
> Is there a straightforward way to overload update related methods across
> several classes?
>
> I'm setting a value in a field called "is_locked", and when it is set to
> 1, I want to ignore any method calls that might update the database.
>
> I want related tables to also obey the is_locked field from the first table.
>
> I have done this by overloading update, set_column, set_columns and
> store_column.
>
> I originally tried to create a derivative class of 'DBIx::Class' called
> 'DBIx::LockingClass' containing the methods, but because of the
> Class::C3 chain, my overloaded methods in 'DBIx::LockingClass' get
> overloaded somewhere else later, and are rendered useless.
So either make LockingClass isa Core, which should put it in front of the
appropriate things anyway, or just load it as a component -
__PACKAGE__->load_components(qw(+My::Locking::Component Core));
Oh, and please keep project-internal modules in a project internal namespace
- if it's in DBIx::Class::* it should be something you got from CPAN (and
preferably something CPAN got from the DBIx::Class repo :)
--
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 DBIx-Class
mailing list