[Catalyst] Accessing a Controller from ~/script

Andrew Rodland arodland at comcast.net
Mon Mar 9 18:09:30 GMT 2009


On Monday 09 March 2009 12:54:34 pm Dermot wrote:
> 2009/2/19 Kieren Diment <kieren at diment.org>:
> > On 19/02/2009, at 11:58 PM, Dermot wrote:
> >> Wow! that works but I am not sure where ACCEPT_CONTEXT comes into it.
> >
> > That'd be if you needed to pass stuff from $c into the model to get it
> > working properly.
>
> I'd like to allow my stand alone model access to the configuration
> values contained in MyApp->config. It seems like the tidy way to do
> things. Does the ACCEPT_CONTEXT method allow me to do this? Is there
> some kinda SUPER way I can grab config and make an accessor of it?

Your Model has its own bit of config space, and this config info is passed to 
its constructor. The advisable thing to do here is to have your config there, 
and have your Model class pass that info along to your backend model class. 
If you need some more complex interaction then you can have more glue in your 
Model class (and ACCEPT_CONTEXT as necessary), but the goal here is not to 
influence your backend class. If the backend class depends on any class 
with 'Catalyst' in the name, or it depends on your app being around so it can 
rummage around in the config structure, then you can't really instantiate it 
outside of Catalyst, so what's the point of splitting it out? "Loose 
coupling" is the word.

Andrew



More information about the Catalyst mailing list