[Catalyst] autoupdate and two minor patches

Frank Wiegand frank.wiegand at gmail.com
Sat Apr 16 10:37:54 CEST 2005


Hi,

3 things:

I. autoupdate with Catalyst::Model::CDBI

Is there any chance to get a new config option to turn autoupdate off in 
Catalyst::Model::CDBI? In my CDBI classes I have some triggers that 
change the values of already set values.

sub trigger {
     my $self = shift;
     $self->set( column => do_something_with( $self->column ) );
}

With autoupdate(1) this runs into an endless loop:
Deep recursion on subroutine "Class::Trigger::call_trigger".

Maybe one could just add another parameter when configure the CDBI::Loader:

 >>>
--- Catalyst/Model/CDBI.pm       2005-04-16 10:32:21.170340768 +0200
+++ /tmp/CDBI.pm        2005-04-16 10:17:37.160730656 +0200
@@ -56,6 +56,7 @@
      $self = $self->NEXT::new($c);
      $self->{namespace}               ||= ref $self;
      $self->{additional_base_classes} ||= ();
+    $self->{autoupdate}              ||= 1;
      push @{ $self->{additional_base_classes} }, ref $self;
      eval { $self->loader( Class::DBI::Loader->new(%$self) ) };
      if ($@) { $c->log->debug(qq/Couldn't load tables "$@"/) if $c->debug }
@@ -65,7 +66,7 @@
            if $c->debug;
      }
      for my $class ( $self->loader->classes ) {
-        $class->autoupdate(1);
+        $class->autoupdate( $self->{autoupdate} );
          $c->components->{$class} ||= bless {%$self}, $class;
          no strict 'refs';
          *{"$class\::new"} = sub { bless {%$self}, $class };
<<<


II. Catalyst::Plugin::FillInForm fails its own t/01use.

 >>>
--- t/01use.t   2005-04-09 00:45:49.000000000 +0200
+++ /tmp/01use.t        2005-04-16 09:26:52.420601512 +0200
@@ -1,4 +1,4 @@
  use strict;
  use Test::More tests => 1;

-BEGIN { use_ok('Catalyst::Plugin::FillForm') }
+BEGIN { use_ok('Catalyst::Plugin::FillInForm') }
<<<


III. __PACKAGE__->setup()

With Cat 5 you'll have to call __PACKAGE__->setup() in your MyApp.pm.
While migrating from version 4 to 5, this took me several hours to find 
out, because it was not mentioned in the documention (the one I read):

 >>>
--- Catalyst/Manual/Intro.pod       2005-04-15 18:47:28.000000000 +0200
+++ /tmp/Intro.pod   2005-04-16 09:20:42.986763992 +0200
@@ -146,6 +146,8 @@
          # my_param_name => $my_param_value,
      );

+    MyApp->setup();
+
      sub default : Private {
          my ( $self, $context ) = @_;
          $context->response->output('Catalyst rockz!');
<<<

All patches are against current CPAN versions.


Frank



More information about the Catalyst mailing list