[Catalyst] Anybody using Chained('.') ?
Jason Kohles
email at jasonkohles.com
Tue Mar 13 16:38:06 GMT 2007
On Mar 13, 2007, at 10:41 AM, Robert 'phaylon' Sedlacek wrote:
> Jason Kohles wrote:
>> I'm trying to use Chained('.') to create a controller base class
>> that binds to the namespace of whatever controller class inherits
>> it, but despite the documentation specifically mentioning this
>> use, I can't seem to get it to work.
>
> Where does the documentation say that? In
> Catalyst::DispatchType::Chained it says
>
> Another interesting possibility gives :Chained('.'), which chains
> itself to an action with the path of the current controller's
> namespace.
>
Apparently I misunderstood the relationship between Chained and
PathPart, and therefore misunderstood what the documentation was
saying here. So now the way I understand it is that Chained('.')
means to setup a chain segment that has as it's parent the chain
segment that matches the current controller's namespace. Apparently
what I'm actually looking for is the equivalent of Chained('/')
PathPart('.'), meaning I want to build chains that originate in the
current namespace.
What I'm actually trying to accomplish is something like this:
package MyApp::CRUDController;
use strict;
use warnings;
use base 'Catalyst::Controller';
# sub base : Chained(???) PathPart(???) CaptureArgs(0) { }
sub id : Chained('base') PathPart('id') CaptureArgs(0) { }
sub list : Chained('base') PathPart('') Args(0) { }
sub view : Chained('id') PathPart('view') Args(0) { }
sub edit : Chained('id') PathPart('edit') Args(0) { }
sub delete : Chained('id') PathPart('delete') Args(0) { }
1;
package MyApp::Controller::Foo;
use strict;
use warnings;
use base 'MyApp::CRUDController';
# So here I would like to get these chained actions:
# /foo/list
# /foo/id/*/view
# /foo/id/*/edit
# /foo/id/*/delete
1;
But the only way I can find to do this with Chained is by putting
something like this in each controller subclass:
sub base : Chained('/') PathPart('foo') CaptureArgs(0) { }
And I would rather not do that if I can avoid it, I'd rather have it
automatic, based on the namespace of the class that is inheriting the
superclass.
--
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing." -- Voltaire
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070313/dbb87230/attachment.htm
More information about the Catalyst
mailing list