[Catalyst] Chained actions in different packages

Xavier Robin robin0 at etu.unige.ch
Mon Oct 23 12:39:44 BST 2006


Hello,

I'm new at Catalyst and I'm doing an application for storing biological 
metadata documents concerning an experiment.

I want (or I would like) to have the following structure of URLs:

(1) /experiment
(2) /experiment/<exp_number>
(3) /experiment/<exp_number>/gel
(4) /experiment/<exp_number>/gel/<gel_number>
(5) /experiment/<exp_number>/gel/<gel_number>/<a_lot_of_actions>

So I have the following actions : 

(1) sub ask_experiment : PathPart('experiment') Chained('/') Args(0) { }
(2) sub show_experiment : PathPart('experiment') Chained('/') Args(1) { }
(3) sub experiment : PathPart('experiment') Chained('/') CaptureArgs(1) { }
And :
(3) sub ask_gel : PathPart('gel') Chained('experiment') Args(0) { }
(4) sub show_gel : PathPart('gel') Chained('experiment') Args(1) { }
(5) sub gel : PathPart('gel') Chained('experiment') CaptureArgs(1) { }

It works fine, exactly as I want it to be.
Now, because of <a_lot_of_actions>, I would like to put all the "gel*" actions 
in a specific package, and "experiment*" in another one.

> package MyApp::Controller::Experiment;
> sub ask_experiment : PathPart('experiment') Chained('/') Args(0) { }
> sub show_experiment : PathPart('experiment') Chained('/') Args(1) { }
> sub experiment : PathPart('experiment') Chained('/') CaptureArgs(1) { }
And
> package MyApp::Controller::Gel;
> sub ask_gel : PathPart('gel') Chained('experiment') Args(0) { }
> sub show_gel : PathPart('gel') Chained('experiment') Args(1) { }
> sub gel : PathPart('gel') Chained('experiment') CaptureArgs(1) { }

But then, it don't work anymore ! :-(
I tried to state the package explicitly in Chained(), for example :

> sub ask_gel : PathPart('gel')
> 	Chained('MyApp::Controller::Experiment::experiment') Args(0) { } 

But it's not better. Only root actions in MyApp::Controller::Experiment are 
recognized. Too bad!
If I "root" my gel* actions (with Chained('/')) they work, but they lose 
the "experiment" part, so it's not what I want.

How can I get my chain of actions working through different packages?

Thanks
Xavier



More information about the Catalyst mailing list