[Dbix-class] Field triggers
Pedro Melo
melo at simplicidade.org
Mon May 7 18:25:30 GMT 2007
Hi,
On May 7, 2007, at 5:17 PM, Jonas Alves wrote:
> On 07/05/07, Pedro Melo <melo at simplicidade.org> wrote:
>> This is what I want to do: when someone inserts or updates a password
>> field, I want to sha1_hex'digest it.
>>
>> I was able to do this overriding both set_column() (for updates) and
>> insert() (for inserts). Is this the best way?
>>
>> Should I use the inflate_column instead?
>
> You can use DBIx::Class::DigestColumns
>
> __PACKAGE__->load_components(qw/DigestColumns Core/);
>
> __PACKAGE__->digestcolumns(
> columns => [qw/password/],
> algorithm => 'SHA-1',
> encoding => 'hex',
> dirty => 1,
> auto => 1,
> );
I did not knew about DigestColumns, and it would be a solution, but I
also have to deal with some legacy passwords stored in crypt()'ed
form, so I cannot use it out of the box.
But I can see how it was implemented and do the same.
Regardless, if someone is kind enough to answer my question: is there
a clean way to have some function or method called whenever a field
changes besides overriding both set_column and insert?
Thanks,
--
Pedro Melo
Blog: http://www.simplicidade.org/notes/
Jabber ID: melo at simplicidade.org
Use Jabber!
More information about the Dbix-class
mailing list