[Catalyst] table discovery
Jurgen Pletinckx
jurgen.pletinckx at algonomics.com
Thu Oct 6 13:57:05 CEST 2005
| >* is the list of tables regenerated each time, independent of
| >whatever Model classes I have available?
|
| I think so, just look at your debug output, like
| [Thu Oct 6 05:08:52 2005] [catalyst] [debug]
| Loaded tables "sessions uwlognames uwprogress ... uwusers"
Yeah. That's what tipped me off, actually. I had first assumed
that my tables were being loaded/discovered as I accessed the
relevant urls, as in host:3000/tablename/list, but then I saw
the debug message you mention during startup.
| >* if it is generated, this happens probably through
| >Class::CBI::Loader->tables. Can I access this method (or the
| >list of tables) from within my app? MyApp::M::CDBI->tables
| >and variations on that theme don't seem to do it.
|
| What worked for me was
| $cdbi_class->loader->tables
| where $cbdi_class is your model component class that did the
| use base 'Catalyst::Model::CDBI';
| The other Class::DBI::Loader methods like find_class()
| will also be available this way. Of course this must be
| done after setup() has been called.
Um. Apparently I need my hand held a bit further. What I
have:
base model class: lib/MyApp/M/CDBI.pm
what fails spectacularly:
$c->log->debug(join "\t", MyApp::M::CDBI->loader->tables);
with the message
Caught exception "Can't use string ("MyApp::M::CDBI") as a HASH ref while
"strict refs" in use at
/usr/local/lib/perl5/site_perl/5.8.7/Class/Accessor/Fast.pm line 38."
On the other hand,
$c->stash->{tables} = [$c->comp("MyApp::M::CDBI")->loader->tables];
does the trick. Hooray. But, shouldn't the first version work as well?
I'm definitely not done assimilating the Catalyst way of thinking.
Cheers,
--
Jurgen Pletinckx
More information about the Catalyst
mailing list