[Catalyst] Access Catalyst context object from script

Ian Docherty catalyst at iandocherty.com
Wed Oct 31 11:29:12 GMT 2012


On 31 October 2012 10:41, Anthony Gladdish
<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?
>
I can understand the reluctance to hard-code URIs, however i would be
reluctant to suggest that you bring in the whole of Catalyst just to
satisfy this one requirement.

What is the template? I presume it is an email, and that you are
putting links to locations within your Catalyst application into the
email?

What form of uri_for are you using? If it is just to capture the
applications root then could you replace it with your own convenience
routine that just implemented that aspect of what uri_for is doing
without bringing in the whole of Catalyst?

Regards
Ian



More information about the Catalyst mailing list