I'm trying to put together my first simple Catalyst application, a foreign
language word quiz, and I'm a bit lost.

In a simple program that uses DBIx::Class only, I might write:

my @langs = $schema->resultset('Language')->all;

I get a list of objects back of class Quiz::Schema::Language, as expected.

In a handler in my Catalyst application, I'm writing:

my @langs = $c->model('Language')->all;

What I get back is a list of objects of class Quiz::Model::DB::Language.
This leaves me scratching my head, since $c->model('Language') gives a
DBIx::Class::ResultSet object, yet it's returning objects that are
associated with my Catalyst class hierarchy.  I had understood DBIx::Class
to be an orthogonal component of my Catalyst app, but they seem to be
intergrated here somehow.

As far as I can recall, nowhere in the various Catalyst tutorials I worked
through was it ever mentioned that ORM objects returned by my model would be
wrapped by, or coerced into, or whatever, subpackages of my model class.
Whatever Quiz::Model::DB::Language is, it's not a transparent wrapper,
because when I call the count() method on one such object of which I know
there should be three, I get undef (or possibly an empty string) back.

Even stranger, when I walk my objects' has_many accessors, I sometimes get
objects that are in a subpackage of my model class, as described above, but
I also sometimes get unblessed array references.  For example, in my current
schema each language has_many sources, and each source has_many termsets.  I
have two languages in my database now, each with one source, each with one
termset.

[% FOR l IN lang; FOR s IN l.sources; s.termsets; END; END %]

This TT snippet prints

Quiz::Model::DB::Termset=HASH(0xcaa4d8)
ARRAY(0xca4fb4)

So now I'm completely confused.  Any help would be massively appreciated.
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to