[Catalyst] Re: How to print/display some data in an end action

Emmanuel Quevillon tuco at pasteur.fr
Mon May 5 08:29:09 BST 2008


Aristotle Pagaltzis wrote:
> * Andreas Marienborg <omega at palle.net> [2008-05-01 10:50]:
>> No point in forwarding to end, since that is done automaticly.
> 
> In which case it would run twice, actually. But maybe he has a
> more specific `end` action and so forwarding to ::C::Root::end
> is actually a useful thing to do in his app. As I said, we have
> seen too little of the code to make any meaningful suggestions.
> 
> Regards,


Hi Aristotle,

You're right, Root/end action is called twice :

| /auto                   | 0.002877s |
| /admin/auto             | 0.001081s |
| /admin/display          | 0.136538s |
|  -> MycoBiblio::View::TT->process 
      | 0.098517s |
| /end                    | 0.000431s |

...
...

| /auto                   | 0.002108s |
| /admin/auto             | 0.000884s |
| /admin/rg               | 0.053757s |
| /end                    | 0.000521s |

We see that in the first call list, the template is well 
called and process correctly as asked in the 'display' code 
action method.
Then the first 'end' call.

Then as in the 'execute' method from C::A::RenderView, it is 
forwarded to the appropriate view, so in 'display' to 
'C::V::TT'.

Then, in the second 'end' call, nothing is forwarded to any 
view as it is asked in C::A::RenderView 'execute' action.

So this is the behavior I wanted :) even if 'end' is called 
twice.


 From C::A::RenderView
---------------------

sub execute {
     my $self = shift;
     my ($controller, $c ) = @_;
     $self->NEXT::execute( @_ );
...
...
     return 1 if $c->req->method eq 'HEAD';
     return 1 if defined $c->response->body && length( 
$c->response->body );
     return 1 if scalar @{ $c->error } && 
!$c->stash->{template};
     return 1 if $c->response->status =~ /^(?:204|3\d\d)$/;
     my $view = $c->view()
         || die "Catalyst::Action::RenderView could not find 
a view to forward to.\n";
     $c->forward( $view );
};
-- 
-------------------------
Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------



More information about the Catalyst mailing list