[Catalyst] detach behaviour clarification

Antano Solar solar345 at gmail.com
Thu Nov 1 18:02:17 GMT 2007


On 11/1/07, Geoff Flarity <geoff.flarity at gmail.com> wrote:
>
> Hi everyone,
>
> I've seem to run into a behavior discrepancy between the included dev
> server and apache when using $c->detach. But I'd like to confirm my
> understanding of exactly how detach should behave before I debug any futh=
er.
> Please consider the following example:
>
> sub one : Local {
>   my ($self, $c ) =3D @_;
>   $c->forward( '_two')
>   $c->stash->{template} =3D 'one.tt2'
> }
>
> sub two : Private {
>   my ($self, $c ) =3D @_;
>   $c->detach('_three');
>   $c->stash->{template} =3D 'two.tt2'
> }
>
> sub three : Private {
>  my ($self, $c ) =3D @_;
>  $c->stash->{template} =3D 'three.tt2';
> }
>
> My current understanding is that the value of template should be three.tt=
2.
> Is this correct?
>
> Thanks,
> Geoff
>
> No !
When you use forward unlike detach the  statements that follow the forward
are also executed.
Which means , the last statement to be executed should be
$c->stash->{template} =3D 'one.tt2'

Antano Solar John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071101/50e59=
2f8/attachment.htm


More information about the Catalyst mailing list