>-----Original Message----- >From: Ian Docherty [mailto:catal...@iandocherty.com] >Sent: 31 October 2012 11:29 >To: The elegant MVC web framework >Subject: Re: [Catalyst] Access Catalyst context object from script > >On 31 October 2012 10:41, Anthony Gladdish ><anthony.gladd...@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?
Correct. It's a bog standard .tt file printing text to be sent as an email, containing links to actions within the Cat app. >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? [% Catalyst.uri_for(Catalyst.controller('MyController').action_for('myaction'), [ some_id ] ) %] Could you offer an example, based on my uri_for example above? Thanks, Anthony _______________________________________________ List: Catalyst@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/