[Catalyst] 'require' vs 'use' in Catalyst*
Matt S Trout
dbix-class at trout.me.uk
Thu Aug 10 20:56:35 CEST 2006
Rodney Broom wrote:
> From: "Joel Bernstein" <joel at fysh.org>
>
>> On Thu, Aug 10, 2006 at 10:28:47AM -0700, Rodney Broom wrote:
>>> Disliking the fact that require() doesn't call my import(), I'm trying to figure out why Catalyst (and so many other things) use require() over use(). I have to think there's a good reason that just isn't occuring to me.
>> require is runtime, use is compile-time.
>
> Right.
>
>
>> Perl doesn't know at compile-time which plugins you're going to load.
>
> Sorry, I'm missing how that effects the choice of require over use. Plugins are found via Module::Pluggable::Object::plugins() in Catalyst::setup_components(), yes?
>
>
> The primary (or initial) reason I want use() is because I want my import called from my schema class:
>
> package MyApp::Schema::Main;
>
> use base qw(DBIx::Class::Schema);
> sub import {
> __PACKAGE__->load_classes(@_);
> }
>
> With require(), I'm forced to call import() explicity in that package.
>
> Under Catalyst, I get all classes. Outside of Catalyst (scripts) I tend to only use what I need:
package MyApp::Model::Main;
use MyApp::Schema::Main;
use base qw/Catalyst::Model::DBIC::Schema/;
...
More information about the Catalyst
mailing list