Hi,

On May 7, 2007, at 5:17 PM, Jonas Alves wrote:

On 07/05/07, Pedro Melo <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
Use Jabber!



_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to