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

Emmanuel Quevillon tuco at pasteur.fr
Wed Apr 30 13:50:35 BST 2008


Andreas Marienborg wrote:
> 
> On Apr 30, 2008, at 11:51 AM, Emmanuel Quevillon wrote:
> 
>> Hi,
>>
>> I'd like to incorporate an action into an <object> tag that only 
>> prints some data (XML SVG).
>> I have an action in a controller Foo that do this :
>>
>> sub display : Local : Args(1) {
>>    ....
>>    my $t = $object->display_graph();
>>    $c->detach('Foo', 'end', [$t]);
>> }
>>
>> sub end : Private {
>>    my($self, $c) = @_;
>>    my $g = $c->req->args()->[0];
>>    print $g;
>> }
> 
> 
> Never use print.
> 
> use $c->res->write[2], or set $c->res->body[1].
> 
> 
> - andreas
> 
> [1]: 
> http://cpansearch.perl.org/~mramberg/Catalyst-Runtime-5.7012/lib/Catalyst/Response.pm#$res-%3Ebody(%3C$text|$fh|$iofh_object) 
> 
> [2]: 
> http://cpansearch.perl.org/~mramberg/Catalyst-Runtime-5.7012/lib/Catalyst/Response.pm#$res-%3Ewrite(_$data_) 
> 
Hi Andreas,

Thanks for your reply. I tried your solutions without 
success. Catalyst always try to wrap the action result 
'display' into a template. However I don't want it, I just 
want an action that throw data when called. I get an error 
from Catalyst saying it cannot find the template 'display.tt2'.
Cheers

Emmanuel


-- 
-------------------------
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