[Catalyst] error using Sweet

Chisel Wright chisel at herlpacker.co.uk
Thu May 26 21:29:09 CEST 2005


>    Any ideas?

I can't recall the link the was posted on IRC recently, but I snarfed it
for my own M:: base class:

---- cut here ----
package MyApp::M::MyAppDB;

use strict;
use base 'Catalyst::Model::CDBI';

use Catalyst::Model::CDBI::Sweet;
use Class::DBI::AbstractSearch;

__PACKAGE__->config(
  dsn           => 'dbi:Pg:dbname=mydb',
  user          => 'chisel',
  password      => '',
  options       => {},
  relationships => 1,
);

sub new {
  my $class = shift;
  my $self  = $class->NEXT::new(@_);

  foreach my $subclass ( $self->loader->classes ) {
    {
      no strict 'refs';
      unshift @{ $subclass . "::ISA" }, 'Catalyst::Model::CDBI::Sweet';
    }
  }

  return $self;
}
---- cut here ----


I now seem to be able to use the ::Sweet functionality without any
hassle.

I think there are plans to add this info to the pod for ::Sweet, but I
can't be certain of that.


Whilst talking about Sweet, page() requires a $criteria - what's the
suggested $criteria to get *all* records from a table? I'm currently
using:

  { autoincrementcolumn_id => { '>=', 1 } }

which feels a bit hacky to me. [where autoincrementcolumn_id is the
"foo_id SERIAL primary key" column for the table]

Chisel
-- 
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/



More information about the Catalyst mailing list