[CDBI] Trigger - cancel transaction.

Praveen Hombaiah phombaiah at gmail.com
Sun Mar 26 00:23:45 GMT 2006


Hi,
  I'm wanting to check if a user has rights to create an object(Insert it
into the db ).   An idea I have is to check it with a before_create
trigger.  My question is how can I stop the object from being created from
the before_create trigger( without using die in the trigger, which means the
users of the class will have to eval{} all methods to the class.

package App::Person;

App::Person->table( 'app_person ');
App::Person->columns(All => qw/id fname lname job_title description
status/);
App::Person->columns(TEMP => qw/userid/);

OT::Project->add_trigger(before_create  => \&call_before_create);

sub call_before_create {

   unless( App::Permissions->allowed( userid, 'add.person' ) ) {
      # How do I stop the creation of the object,
      # without die?

      # die  "Insufficient privelage to perform requested action\n";
   }

}

1;

or maybe is there a better idiom?

--
Regards,
Praveen Hombaiah.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20060325/1c0d852d/attachment.htm


More information about the ClassDBI mailing list