[Catalyst] Perplexed Catalyst newbie
Sean McAfee
eefacm at gmail.com
Sun Apr 19 19:22:26 GMT 2009
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 =3D $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 =3D $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=3DHASH(0xcaa4d8)
ARRAY(0xca4fb4)
So now I'm completely confused. Any help would be massively appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090419/1fec1=
8f9/attachment.htm
More information about the Catalyst
mailing list