Mailing List Archive

Can't detach from root / create action object
I seem to be going round in circles unable to understand how I create an action object so I can pass it to detach as the IRC has told me to pass in an action and not what I thought which was 'controller_name, subroutine'.

E.G.

$c->detach('my_controller_name','index');

But it seems that this signature is ('class_name', 'subroutine')

I'm having a problem with Catalyst randomly deciding when it is OK to have a controller and a model called the same, as I have in the same root auto subroutine ,

$c->detach('splashscreen','index').

Where I have both a controller called 'SplashScreen' and a model called 'SplashScreen', and the detach works fine.

However, for another controller / model pair called 'ComplianceUpdates',

This doesn't work

$c->detach('complianceupdates','index').

and errors with...

Couldn't forward to "ComplianceUpdates". Does not implement "process"

Couldn't detach to command "complianceupdates": Invalid action or component.
So If I am to use

$c->detach($action);

How do I create a Catalyst::Action object.

What attributes am I meant to be setting in the object before I pass it in, and where are the docs for this as I can't find them.

All help is appreciated.


Craig Chant
Information Technology Manager

[Description: Description: HLP_IT_Sig1]

Direct Line: 01903 227 753 Main Line: 01903 602 664 Website: www.homeloanpartnership.com<http://www.homeloanpartnership.com>

[Description: Description: HLP_Sig2_variant]

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.
Re: Can't detach from root / create action object [ In reply to ]
You should tell us what you want to achieve.

"I want to pass an action to detach()" is not a proper problem description.


The documentation is pretty clear on what is expected.
https://metacpan.org/pod/Catalyst#c-detach-action-arguments

$c->detach( $action [, \@arguments ] )
$c->detach( $class, $method, [, \@arguments ] )
$c->detach()

Have you checked the Catalyst Tutorial. It should provide examples for detach()
There is also the test suite which you can grep for detach.





On 27 November 2013 13:00, Craig Chant <craig@homeloanpartnership.com> wrote:
> I seem to be going round in circles unable to understand how I create an
> action object so I can pass it to detach as the IRC has told me to pass in
> an action and not what I thought which was ‘controller_name, subroutine’.
>
>
>
> E.G.
>
>
>
> $c->detach(‘my_controller_name’,’index’);
>
>
>
> But it seems that this signature is (‘class_name’, ‘subroutine’)
>
>
>
> I’m having a problem with Catalyst randomly deciding when it is OK to have a
> controller and a model called the same, as I have in the same root auto
> subroutine ,
>
>
>
> $c->detach(‘splashscreen’,’index’).
>
>
>
> Where I have both a controller called ‘SplashScreen’ and a model called
> ‘SplashScreen’, and the detach works fine.
>
>
>
> However, for another controller / model pair called ‘ComplianceUpdates’,
>
>
>
> This doesn’t work
>
>
>
> $c->detach(‘complianceupdates’,’index’).
>
>
>
> and errors with…
>
> Couldn't forward to "ComplianceUpdates". Does not implement "process"
>
> Couldn't detach to command "complianceupdates": Invalid action or component.
>
> So If I am to use
>
>
>
> $c->detach($action);
>
>
>
> How do I create a Catalyst::Action object.
>
>
>
> What attributes am I meant to be setting in the object before I pass it in,
> and where are the docs for this as I can’t find them.
>
>
>
> All help is appreciated.
>
>
>
>
>
> Craig Chant
>
> Information Technology Manager
>
>
>
>
>
> Direct Line: 01903 227 753 Main Line: 01903 602 664 Website:
> www.homeloanpartnership.com
>
>
>
>
>
> 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.
>
> _______________________________________________
> 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/
>
Re: Can't detach from root / create action object [ In reply to ]
On 2013-11-27 13:00, Craig Chant wrote:
I seem to be going round in circles unable to understand how I create an action object so I can pass it to detach as the IRC has told me to pass in an action and not what I thought which was 'controller_name, subroutine'.

E.G.

$c->detach('my_controller_name','index');

But it seems that this signature is ('class_name', 'subroutine')

I'm having a problem with Catalyst randomly deciding when it is OK to have a controller and a model called the same, as I have in the same root auto subroutine ,

$c->detach('splashscreen','index').

Where I have both a controller called 'SplashScreen' and a model called 'SplashScreen', and the detach works fine.

However, for another controller / model pair called 'ComplianceUpdates',

This doesn't work

$c->detach('complianceupdates','index').

and errors with...

Couldn't forward to "ComplianceUpdates". Does not implement "process"

Couldn't detach to command "complianceupdates": Invalid action or component.
So If I am to use

$c->detach($action);

How do I create a Catalyst::Action object.
Exactly like I just told you on IRC: $c->detach($c->controller('ComplianceUpdate')->action_for('index'));

What attributes am I meant to be setting in the object before I pass it in, and where are the docs for this as I can't find them.

All help is appreciated.


Craig Chant
Information Technology Manager

[Description: Description: HLP_IT_Sig1]

Direct Line: 01903 227 753 Main Line: 01903 602 664 Website: www.homeloanpartnership.com<http://www.homeloanpartnership.com>

[Description: Description: HLP_Sig2_variant]

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.


_______________________________________________
List: Catalyst@lists.scsys.co.uk<mailto: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/




*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
RE: Can't detach from root / create action object [ In reply to ]
No the documentation isn't clear, if I could understand it I wouldn’t be asking this question.

What is $action ? And yes I've looked at the manual.

Chapter 3 when you search for 'detach' states..

NOTE: If you use the default template technique, you will not be able to use either the $c->forward or the $c->detach mechanisms (these are discussed in Chapter 2 and Chapter 9 of the Tutorial).

So I go back to chapter 2 and search for detach and get zero results the same when I search chapter 9?

Not sure why you seem to think the tutorial is clear, when I seem to be going round in circles?


-----Original Message-----
From: David Schmidt [mailto:davewood@gmx.at]
Sent: 27 November 2013 12:24
To: The elegant MVC web framework
Subject: Re: [Catalyst] Can't detach from root / create action object

You should tell us what you want to achieve.

"I want to pass an action to detach()" is not a proper problem description.


The documentation is pretty clear on what is expected.
https://metacpan.org/pod/Catalyst#c-detach-action-arguments

$c->detach( $action [, \@arguments ] )
$c->detach( $class, $method, [, \@arguments ] )
$c->detach()

Have you checked the Catalyst Tutorial. It should provide examples for detach() There is also the test suite which you can grep for detach.





On 27 November 2013 13:00, Craig Chant <craig@homeloanpartnership.com> wrote:
> I seem to be going round in circles unable to understand how I create
> an action object so I can pass it to detach as the IRC has told me to
> pass in an action and not what I thought which was ‘controller_name, subroutine’.
>
>
>
> E.G.
>
>
>
> $c->detach(‘my_controller_name’,’index’);
>
>
>
> But it seems that this signature is (‘class_name’, ‘subroutine’)
>
>
>
> I’m having a problem with Catalyst randomly deciding when it is OK to
> have a controller and a model called the same, as I have in the same
> root auto subroutine ,
>
>
>
> $c->detach(‘splashscreen’,’index’).
>
>
>
> Where I have both a controller called ‘SplashScreen’ and a model
> called ‘SplashScreen’, and the detach works fine.
>
>
>
> However, for another controller / model pair called
> ‘ComplianceUpdates’,
>
>
>
> This doesn’t work
>
>
>
> $c->detach(‘complianceupdates’,’index’).
>
>
>
> and errors with…
>
> Couldn't forward to "ComplianceUpdates". Does not implement "process"
>
> Couldn't detach to command "complianceupdates": Invalid action or component.
>
> So If I am to use
>
>
>
> $c->detach($action);
>
>
>
> How do I create a Catalyst::Action object.
>
>
>
> What attributes am I meant to be setting in the object before I pass
> it in, and where are the docs for this as I can’t find them.
>
>
>
> All help is appreciated.
>
>
>
>
>
> Craig Chant
>
> Information Technology Manager
>
>
>
>
>
> Direct Line: 01903 227 753 Main Line: 01903 602 664 Website:
> www.homeloanpartnership.com
>
>
>
>
>
> 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.
>
> _______________________________________________
> 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/
>
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.
RE: Can't detach from root / create action object [ In reply to ]
Thanks Alexander,

I must have missed this : $c->detach($c->controller('ComplianceUpdate')->action_for('index'));

It's working as desired, much appreciated.

Craig.

From: Hartmaier Alexander [mailto:alexander.hartmaier@t-systems.at]
Sent: 27 November 2013 12:25
To: catalyst@lists.scsys.co.uk
Subject: Re: [Catalyst] Can't detach from root / create action object

On 2013-11-27 13:00, Craig Chant wrote:

I seem to be going round in circles unable to understand how I create an action object so I can pass it to detach as the IRC has told me to pass in an action and not what I thought which was 'controller_name, subroutine'.

E.G.

$c->detach('my_controller_name','index');

But it seems that this signature is ('class_name', 'subroutine')

I'm having a problem with Catalyst randomly deciding when it is OK to have a controller and a model called the same, as I have in the same root auto subroutine ,

$c->detach('splashscreen','index').

Where I have both a controller called 'SplashScreen' and a model called 'SplashScreen', and the detach works fine.

However, for another controller / model pair called 'ComplianceUpdates',

This doesn't work

$c->detach('complianceupdates','index').

and errors with...

Couldn't forward to "ComplianceUpdates". Does not implement "process"

Couldn't detach to command "complianceupdates": Invalid action or component.
So If I am to use

$c->detach($action);

How do I create a Catalyst::Action object.
Exactly like I just told you on IRC: $c->detach($c->controller('ComplianceUpdate')->action_for('index'));

What attributes am I meant to be setting in the object before I pass it in, and where are the docs for this as I can't find them.

All help is appreciated.


Craig Chant
Information Technology Manager

[Description: Description: HLP_IT_Sig1]

Direct Line: 01903 227 753 Main Line: 01903 602 664 Website: www.homeloanpartnership.com<http://www.homeloanpartnership.com>

[Description: Description: HLP_Sig2_variant]

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.


_______________________________________________

List: Catalyst@lists.scsys.co.uk<mailto: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/



*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
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.
Re: Can't detach from root / create action object [ In reply to ]
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) = @_;
$c->detach('my_action_1');
}

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

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

Is it clearer now?

Cheers!
André


_______________________________________________
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/
RE: Can't detach from root / create action object [ In reply to ]
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 :-

$c->detach($c->controller('ComplianceUpdate')->action_for('index'));

So I assume

$c->controller('ComplianceUpdate')->action_for('index');

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' => [
'complianceupdates'
],
'Args' => [
'0'
]
},
'reverse' => 'complianceupdates/index',
'code' => sub { "DUMMY" }
}, 'Catalyst::Action' );"


Having just tested with : -

$c->detach('/complianceupdates/index');

is working.

So the question now is which is better...

$c->controller('ComplianceUpdate')->action_for('index');

or

$c->detach('/complianceupdates/index');

Pass a string or a pass an object?

Thanks,

Craig.

-----Original Message-----
From: André Walker [mailto:andre@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) = @_;
$c->detach('my_action_1');
}

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

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

Is it clearer now?

Cheers!
André


_______________________________________________
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/
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.
Re: Can't detach from root / create action object [ In reply to ]
On Wed, Nov 27, 2013 at 02:51:23PM +0000, Craig Chant wrote:
> So I assume
>
> $c->controller('ComplianceUpdate')->action_for('index');
>
> is returning an action object that is passed to detach.

True.

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

It's not :) Catalyst magically converts that for you.

See this:

https://metacpan.org/source/JJNAPIORK/Catalyst-Runtime-5.90051/lib/Catalyst/Dispatcher.pm#L148

It either gets an action object, or it translates the path to an object for
you.

> Having just tested with:
>
> $c->detach('/complianceupdates/index');
>
> is working.
>
> So the question now is which is better...
>
> $c->controller('ComplianceUpdate')->action_for('index');
>
> or
>
> $c->detach('/complianceupdates/index');
>
> Pass a string or a pass an object?

I like the string option better. It's cleaner to read. But you should be fine
with both.

Cheers,
André


_______________________________________________
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/
RE: Can't detach from root / create action object [ In reply to ]
Awesome, thanks for demystifying this for me!

# go to a string path ("/foo/bar/gorch")
# or action object
if (blessed($command) && $command->isa('Catalyst::Action')) {
$action = $command;
}
else {
$action = $self->_invoke_as_path( $c, "$command", \@args );
}

I'm still at a loss why when I was using the wrong syntax, it was working for SplashScreen, but the same syntax for ComplianceUpdates wasn't!

And I still can't find where in the docs/tutorial any of this is explained? (a section and page number would be helpful!)

Regards,

Craig.


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

On Wed, Nov 27, 2013 at 02:51:23PM +0000, Craig Chant wrote:
> So I assume
>
> $c->controller('ComplianceUpdate')->action_for('index');
>
> is returning an action object that is passed to detach.

True.

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

It's not :) Catalyst magically converts that for you.

See this:

https://metacpan.org/source/JJNAPIORK/Catalyst-Runtime-5.90051/lib/Catalyst/Dispatcher.pm#L148

It either gets an action object, or it translates the path to an object for you.

> Having just tested with:
>
> $c->detach('/complianceupdates/index');
>
> is working.
>
> So the question now is which is better...
>
> $c->controller('ComplianceUpdate')->action_for('index');
>
> or
>
> $c->detach('/complianceupdates/index');
>
> Pass a string or a pass an object?

I like the string option better. It's cleaner to read. But you should be fine with both.

Cheers,
André


_______________________________________________
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/
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.

_______________________________________________
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/
Re: Can't detach from root / create action object [ In reply to ]
From: "Craig Chant" <craig@homeloanpartnership.com>

> 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 :-
>
> $c->detach($c->controller('ComplianceUpdate')->action_for('index'));
>
> So I assume
>
> $c->controller('ComplianceUpdate')->action_for('index');
>
> 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?



Below is a piece of text I created for the Catalyst documentation a long
time ago (perldoc Catalyst).
It tries to makes the things a little bit clearer for using uri_for_action()
method, but it is the same in any case an action path is used.
The idea is that even though the action path looks like a URL, it is not an
URL. It is not the URL that calls that action.

""
Note that although the path looks like a URI that dispatches to the
wanted action, it is not a URI, but an internal path to that action.

For example, if the action looks like:

package MyApp::Controller::Users;

sub lst : Path('the-list') {}

You can use:

$c->uri_for_action('/users/lst')

and it will create the URI /users/the-list.
""

--Octavian


_______________________________________________
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/
RE: Can't detach from root / create action object [ In reply to ]
Good morning,

On 27/11/13 at 2:51 PM -0000, Craig Chant
<craig@homeloanpartnership.com> wrote:

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

Being pedantic here, but it doesn't accept a URL path; it
accepts an action path. Often they are the same, but they don't
need to be.

# in Root Controller
sub my_list :Path('list') { ... }

You would pass /my_list to detach, but the URL for that action
would be /list.


Charlie

--
Ꮚ Charlie Garrison ♊ <garrison@zeta.org.au>

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
〠 http://www.ietf.org/rfc/rfc1855.txt


_______________________________________________
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/
RE: Can't detach from root / create action object [ In reply to ]
Hi Charlie,

So it is a URI for a method name in the controller class object you wish to execute.

So rather than matching it as a Path URL, it matches it a as a 'ControllerClass/Method'

So for the URL path in my case would be '/complianceupdates/' , but for detach it is '/complianceupdates/index'

As index is the name of the method that handles the '/' path.

Got it! Many thanks,

Craig.

-----Original Message-----
From: Charlie Garrison [mailto:garrison@zeta.org.au]
Sent: 27 November 2013 22:47
To: The elegant MVC web framework
Subject: RE: [Catalyst] Can't detach from root / create action object

Good morning,

On 27/11/13 at 2:51 PM -0000, Craig Chant <craig@homeloanpartnership.com> wrote:

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

Being pedantic here, but it doesn't accept a URL path; it accepts an action path. Often they are the same, but they don't need to be.

# in Root Controller
sub my_list :Path('list') { ... }

You would pass /my_list to detach, but the URL for that action would be /list.


Charlie

--
Ꮚ Charlie Garrison ♊ <garrison@zeta.org.au>

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
〠 http://www.ietf.org/rfc/rfc1855.txt


_______________________________________________
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/
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.
Re: Can't detach from root / create action object [ In reply to ]
* Hartmaier Alexander <alexander.hartmaier@t-systems.at> [2013-11-27 13:30]:
> Exactly like I just told you on IRC:
> $c->detach($c->controller('ComplianceUpdate')->action_for('index'));

Or using an action path:

$c->detach( $c->dispatcher->get_action_by_path('/complianceupdate/index') );

It’s a mouthful so if you need it lots, stick a method in your
application class à la

sub path_action {
my $c = shift;
$c->dispatcher->get_action_by_path( @_ );
}

so you can then say

$c->detach( $c->path_action('/complianceupdate/index') );

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
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/
Re: Can't detach from root / create action object [ In reply to ]
On 2013-11-28 10:43, Craig Chant wrote:

Hi Charlie,

So it is a URI for a method name in the controller class object you wish to execute.

So rather than matching it as a Path URL, it matches it a as a 'ControllerClass/Method'

So for the URL path in my case would be '/complianceupdates/' , but for detach it is '/complianceupdates/index'

As index is the name of the method that handles the '/' path.

Got it! Many thanks,

The advantage or all this is that you change change your url layout without touching the code at all.



Craig.

-----Original Message-----
From: Charlie Garrison [mailto:garrison@zeta.org.au]
Sent: 27 November 2013 22:47
To: The elegant MVC web framework
Subject: RE: [Catalyst] Can't detach from root / create action object

Good morning,

On 27/11/13 at 2:51 PM -0000, Craig Chant <craig@homeloanpartnership.com><mailto:craig@homeloanpartnership.com> wrote:



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



Being pedantic here, but it doesn't accept a URL path; it accepts an action path. Often they are the same, but they don't need to be.

# in Root Controller
sub my_list :Path('list') { ... }

You would pass /my_list to detach, but the URL for that action would be /list.


Charlie

--
? Charlie Garrison ? <garrison@zeta.org.au><mailto:garrison@zeta.org.au>

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org<http://www.asciiribbon.org>
? http://www.ietf.org/rfc/rfc1855.txt


_______________________________________________
List: Catalyst@lists.scsys.co.uk<mailto: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/
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.




_______________________________________________
List: Catalyst@lists.scsys.co.uk<mailto: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/




*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*