[Catalyst] Access custom TT filters outside of catalyst context

Kieren Diment diment at gmail.com
Sat Dec 13 04:34:51 GMT 2008


On 13/12/2008, at 3:03 PM, J. Shirley wrote:

> On Fri, Dec 12, 2008 at 4:01 PM, Kieren Diment <diment at gmail.com>  
> wrote:
>> That's the only place to have $c in the entire code, and you only  
>> copy over
>> the bits that you want:
>>
>> $self = bless({ %$self,
>>                model_accessor => $c->model('MyModel')->whatever,
>>            }, ref($self));
>> return $self;
>>
>> then in view::TT:
>>
>> sub whatever {
>> my $self = @_;
>> $self->model_accessor->do_stuff;
>> ...
>> }
>>
>
> But what if $c never exists, because you are writing a command line
> application that never invokes Catalyst?


I've used this technique in a script that does:

use MyApp;
my $thing = MyApp->model->thing_from_accept_context_method ....

which is acceptable for me as my code is tightly coupled to the actual  
web app and accessing outside the web app is just a convenience issue,  
but might not be to everyone's taste.



More information about the Catalyst mailing list