[Catalyst] Any chance there is an arbitrary limit to how many classes you can load this way...?

John Romkey romkey at apocalypse.org
Wed Oct 10 04:58:30 GMT 2007


Try making sure that you fully qualify all your model and view names,  
and that they're the correct names, no typos.

So, instead of:

$c->view('Foo')

use

$c->view('MyApp::View::Foo')

For quite a while I was running into problems where I'd get the wrong  
view or even the wrong resultset. I was new to Catalyst and wasn't  
sure whether it was a problem with the way I was using it.

One particular model problem I had was that I was trying to use the  
User table for authentication but for some reason the authentication  
plugin was getting UserRole and blowing up on me.

The weirdest thing was that my app worked fine until I added a few  
more tables and then suddenly this started happening.

I wrote some test code that made sure the problem wasn't DBIx::Class.  
It was definitely happening inside Catalyst.

I finally realized that I wasn't fully qualifying my model and view  
names. Catalyst's component name lookup falls back into a regex  
search and sometimes this was getting kicked into and returning me  
the wrong component. I went back through my code and fully qualified  
each model resultset name and each view name and the problem vanished.

Good luck,
	- john romkey
	http://www.romkey.com/

On Oct 9, 2007, at 4:51 AM, Dustin Suchter wrote:

> So let's assume I have the below code. Each of the 13 classes
> represent 1 table in the same MySQL db. All class definitions are
> essentially identical in structure and have nothing more complex
> than foreign keys in them.
>
> Here's the weird thing, if I run my code with all 13 classes, my
> default view stops working - it seems to be replaced with the only
> other view I've defined! I only use the other one by manually
> calling 'forward' to it in 1 function - ultra weird!
>
> If I remove any of the classes the load_classes line the behavior
> goes back to expected. I've tried lots of reordering, renaming,
> removing, etc etc. I actually have far more than 13 classes I want
> to load, so I've even tried interchanging which 13 I test with. As
> far as I can tell, loading more than 12 classes at a time here
> causes some sort of buffer overflow that ends up messing with my
> views. That really doesn't make any sense to me, but it is what I'm
> observing.
>
> Also, I notice that in the debug output when starting my server,
> both my views are present at all times, so it's not like the
> secondary view is getting used because the default one is missing.
>
> However, if I delete the class defining my secondary view then my
> default view starts working again. This seems to imply that having
> more than 12 classes loaded in my Model somehow changes my default
> view order...?!
>
> umm... help? =]
>
> ###############
> package MyAppDB;
>
> use base qw/DBIx::Class::Schema/;
> __PACKAGE__->load_classes({
>     MyAppDB => [qw/One Two Three Four Five Six Seven Eight Nine Ten
> Eleven Twelve Thirteen/]
> });
>
> ###############
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/ 
> catalyst at lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list