[Catalyst] error using Sweet

Alan Humphrey alan.humphrey at comcast.net
Thu May 26 21:57:37 CEST 2005


Thank you.  That's got me on the road again.  On to the next problem.

BTW, empty criteria are supposed to be supported.

my $criteria = {};
my ($page, $iterator) = My::Class->page( $criteria );

Thanks to your tip, it appears to be working for me.

-----Original Message-----
From: catalyst-bounces at lists.rawmode.org
[mailto:catalyst-bounces at lists.rawmode.org] On Behalf Of Chisel Wright
Sent: Thursday, May 26, 2005 11:29 AM
To: Catalyst
Subject: Re: [Catalyst] error using Sweet

>    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/

_______________________________________________
Catalyst mailing list
Catalyst at lists.rawmode.org
http://lists.rawmode.org/mailman/listinfo/catalyst




More information about the Catalyst mailing list