On 10 May 2008, at 15:12, Matt S Trout wrote:

On Fri, May 09, 2008 at 01:00:07PM +0100, Tomas Doran wrote:
sub format :Chained PathPart('format') Args(1) {}

Inherit that into both controllers.

__PACKAGE__->config(actions => { format => { Chained => 'tracksequence' } });

in one controller, and 'trackonvolume' in the other.

Then you have two format endpoints but one 'sub format'.

Problem solved.


Aha, much neater / more D.R.Y. thanks. :)

However, this does mean I now have 3 packages (a base class, and two controllers), where before I had one file..

The actual controller code for all of this stuff is pretty small (as it's just asking the model stuff, and stashing it at each stage), and it will be much less visually clear what the hell is going on to have it spread across three packages..

Is there any semantic problem with the idea of being able to chain a sub to multiple places? (E.g.sub format : Chained('tracksequence') Chained('trackonvolume') PathPart('format') Args(1) {}) ?

After hacking a round a little yesterday, I've got the syntax as suggested above kinda working, and I'll probably keep fiddling with it unless someone can give me some good reasons why having multiple Chained attributes should be forbidden (as, lets face it - splitting my code into 3 packages and inheriting *in this case* is, a hack to get round Chained not playing how I'd like it to)..

Cheers
Tom




_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to