[CDBI] Subclass won't inherit trigger?

Phil Mitchell seasprocket at gmail.com
Mon Oct 3 18:01:45 BST 2005


I have a Page class with a before_create trigger. Page has a subclass,
User, which (of course) inherits the trigger. When I added an
after_create trigger to User, it stops inheriting the before_create
trigger. This is not good, since creation fails without the setup in
before_create. This arrangement works fine with other subclasses.

User's cdbi setup:

sub essential_columns {
  my @essential = Reef::M::DBI::Page->_essential;
  push @essential, qw/username password person_name email/;
  push @essential, $GEO_VALIDATION->core_location_fields();
  return @essential
}

__PACKAGE__->columns(Essential => __PACKAGE__->essential_columns);
__PACKAGE__->add_trigger(after_create  => \&_after_create);

Here's Page:

__PACKAGE__->table('page');
__PACKAGE__->columns(Primary => qw/id /);

__PACKAGE__->columns(Essential => qw/page_type
                                     created
                                     edit_date
                                     edit_by
                                     user_owner
                                     club_owner
                                     permissions
                                     locked_since
                                     locked_by
                                     title
                                     body /);

__PACKAGE__->columns(Others => qw/shelf /);

__PACKAGE__->has_a(shelf        => 'Reef::M::DBI::Shelf');
__PACKAGE__->has_a(locked_by    => 'Reef::M::DBI::Page::User');
__PACKAGE__->has_a(edit_by      => 'Reef::M::DBI::Page::User');
__PACKAGE__->has_a(user_owner   => 'Reef::M::DBI::Page::User');
__PACKAGE__->has_a(club_owner   => 'Reef::M::DBI::Page::Club');

__PACKAGE__->has_a(created => 'DateTime',
		   inflate => sub { DateTime::Format::ISO8601->parse_datetime(shift) },
		   deflate => sub { shift->iso8601() });

__PACKAGE__->has_a(edit_date => 'DateTime',
		   inflate => sub { DateTime::Format::ISO8601->parse_datetime(shift) },
		   deflate => sub { shift->iso8601() });

__PACKAGE__->has_a(locked_since => 'DateTime',
		   inflate => sub { DateTime::Format::ISO8601->parse_datetime(shift) },
		   deflate => sub { shift->iso8601() });

__PACKAGE__->has_many(tags => 'Reef::M::DBI::Tag');

__PACKAGE__->add_trigger(before_create  => \&_before_create);
__PACKAGE__->add_trigger(before_update  => \&_before_update);





--
==========================
2People Blog: http://2-people.blogspot.com/
2People site: http://www.2people.org




More information about the ClassDBI mailing list