[Catalyst] Can't detach from root / create action object

Craig Chant craig at homeloanpartnership.com
Wed Nov 27 14:51:23 GMT 2013

Hi Andre,

That is clearer, and Alexander provided me with a working solution, but it doesn't make sense with your example.

$action is an action object isn't it?

So Alexander's example has :-


So I assume


is returning an action object that is passed to detach.

However, your example just has a string path '/a/my_action_1' , how is that an action object?

Are you  saying detach (for the single argument signature) takes a URL path and that $action is just a string scalar with a URL path in it and not an action object reference as I got the impression?

Or are there two single argument signatures to detach() one takes an Action object and one takes a URL path string?

Because I did a Data::Dumper of

die Dumper($c->controller('ComplianceUpdate')->action_for('index')) and I got an object!

"$VAR1 = bless( {
                 'namespace' => 'complianceupdates',
                 'name' => 'index',
                 'class' => 'HLP_Members::Controller::ComplianceUpdates',
                 'attributes' => {
                                   'Path' => [
                                   'Args' => [
                 'reverse' => 'complianceupdates/index',
                 'code' => sub { "DUMMY" }
               }, 'Catalyst::Action' );"

Having just tested with : -


is working.

So the question now is which is better...




Pass a string or a pass an object?



-----Original Message-----
From: André Walker [mailto:andre at andrewalker.net]
Sent: 27 November 2013 13:04
To: The elegant MVC web framework
Subject: Re: [Catalyst] Can't detach from root / create action object

On Wed, Nov 27, 2013 at 12:36:54PM +0000, Craig Chant wrote:
> No the documentation isn't clear, if I could understand it I wouldn’t
> be asking this question.

I'm sorry you couldn't understand from the documentation. I'll try and explain a little more here:

# lib/MyApp/Controller/A.pm
package MyApp::Controller::A;

sub my_action_1 :Local {
     my ($self, $c) = @_;
     $c->res->body('in action 1');

sub my_action_2 :Local {
     my ($self, $c) = @_;

# lib/MyApp/Controller/B.pm
package MyApp::Controller::A;

sub other_action :Local {
     my ($self, $c) = @_;
     # or
     $c->detach('MyApp::Controller::A', 'my_action_1'); }

Is it clearer now?


List: Catalyst at 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/
This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partnership has the authority to enter into any contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is a trading name of H L Partnership Limited, registered in England and Wales with Registration Number 5011722. Registered office: Pharos House, 67 High Street, Worthing, West Sussex, BN11 1DN. H L Partnership Limited is authorised and regulated by the Financial Conduct Authority.

More information about the Catalyst mailing list