[Catalyst] Access Catalyst context object from script

Rob Brown rob at intelcompute.com
Wed Oct 31 11:29:36 GMT 2012


Your script is not running under Catalyst, so $c, or the Catalyst 
context, is not available.

$c manages HTTP requests and responses.

It sounds like your approach/design may be slightly flawed.  Perhaps 
explain what you're trying to achieve - what are you doing with these 
templates?  where are they going?  why do they have URLs to your 
Catalyst app in them?

Cheers,
Robsco



On 10/31/2012 11:18 AM, Dimitar Petrov wrote:
> Hello Anthony,
>
> I think the catalyst object is not called Catalyst but c, this you need
> [% c.uri_for(...) %] or you can use [% c.uri_for_action(...) %] to point
> to particular action.
> You could change that setting the CATALYST_VAR into your view
> configuration (as shown here
> https://metacpan.org/module/Catalyst::View::TT), however I think "c" is
> shorter and better default.
>
> Cheers
>
>
> On Wed, Oct 31, 2012 at 11:41 AM, Anthony Gladdish
> <anthony.gladdish at newcastle.ac.uk
> <mailto:anthony.gladdish at newcastle.ac.uk>> wrote:
>
>     Hi,
>
>     Got a lot of code in a controller that should be moved out and into
>     an external script (that's called by a cronjob) which calls stuff
>     from the Model and then emails it.
>
>     The script can access the model fine and re-use a Template::Toolkit
>     template already written fine (I'm using MIME::Lite::TT). However,
>     in the template itself there's a lot of calls to the Catalyst
>     context object, in the form of:
>
>              [% Catalyst.uri_for( ... ) %]
>
>     ... which aren't displaying anything. I don't really want to hard
>     code the URIs, so is there a way to get access to the Catalyst
>     context object of a running app, in a separate external script?
>
>     Regards,
>
>     Anthony Gladdish
>
>     _______________________________________________
>     List: Catalyst at lists.scsys.co.uk <mailto: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@lists.scsys.co.uk/
>     Dev site: http://dev.catalyst.perl.org/
>
>
>
>
> _______________________________________________
> 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@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

-- 
IntelCompute
Web Design & Online Marketing Experts

http://www.intelcompute.com



More information about the Catalyst mailing list