[Maypole] Availability of request object to trigger

Jesse Sheidlower jester@panix.com
Tue, 23 Mar 2004 15:45:01 -0500


This probably stems from my lack of knowledge about triggers in
Class::DBI, but I'd like to get some information from the Maypole
request object ($r) into a trigger. Specifically, I want to have
a database column called "last_modified_by" that has the value of
the "id" of the User table of the person who made a change. I
started to write the trigger in my Model class as

__PACKAGE__->add_trigger(before_update => sub {
  my $obj = shift;
  $obj->_attribute_set("last_modified_by", $r->{user}->id);
});

until I realized that I don't have an $r->{user}->id yet.
Can I get this information there, or is there another way
of doing this?

(I realize also that I'd want to make this a standalone sub
so I can call the same sub on before_create, too, but that
doesn't affect the question at hand.)

Thanks.

Jesse Sheidlower