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

Andreas Marienborg omega at palle.net
Thu May 1 09:41:03 BST 2008


On Apr 30, 2008, at 4:16 PM, Emmanuel Quevillon wrote:

> Aristotle Pagaltzis wrote:
>> * Emmanuel Quevillon <tuco at pasteur.fr> [2008-04-30 15:05]:
>>> Catalyst always try to wrap the action result 'display' into a
>>> template.
>> No, it doesn’t. If that happens in your app, then you have set it
>> up to happen like that. But the code you pasted does not include
>> that portion, so no one will be able tell you what to do instead.
>> Regards,
>
>
> Thanks Aristotle,
>
>
> Maybe I can clarify the situation.
>
> In controller Foo I have 2 methods:
>
> sub bar : LocalRegex ('^(\d+)$') {
>
>    my($self, $c) = @_;
>
>    my $id = $c->req->captures->[0];
>    $c->detach(qw/Root _softwareError/,
>               ["An id is required to get related genes."])
>      unless $id;
>
>    $c->stash()->{url}      = $c->uri_for("/admin/rg/$id");
>    $c->stash()->{template} = 'admin/relatedgenes.tt2';
>    $c->detach('View::TT');
>
> }
>
> sub rg : Local : Args(1) {
>
>
>    my($self, $c) = @_;
>
>    my $id = $c->req->args->[0];
>    $c->detach(qw/Root _softwareError/,
>               ["An id is required to get related genes."])
>      unless $id;
>
>    my $gr = GeneRelations->new(
>        %{$c->config()->{dbinfos}},
>        org  => $c->session()->{org}->{id_org},
>       );
>
>    my $t = $gr->display_graph(type => 'id_gene', value => $id);
>    $c->res->write($t);
>    $c->forward('Root', 'end');
>
> }
>
>
> Template 'admin/relatedgenes.tt2' contains an <object> tag as :
>
> <object data="[% url %]" width="100%" height="100%"></object>
>
> with [% url %] value coming from 'Foo::bar'
> here: <object data="http://..../rg/<id>"></object>
>
> I know that <object> tag can contain an url to be call on load, and  
> that's what I want to do with My app to avoid storing svg files. If  
> I put url for a svg image it works fine. But I don't want to store  
> temp files.
>
> I hope the situation will be clearer like this and someone will be  
> able to give clues or solutions.


Most likely your Root's end action forwards to a view. If you use the  
RenderView action-class, it shouldn't do that if the body is set.

I would change the rg actions last few lines to something like this:


$c->res->body($t);
$c->res->content_type('your/content-type');
}

No point in forwarding to end, since that is done automaticly.

If you don't use RenderView, you need to post your roots end action if  
we are to help you figure out whats up there.

- andreas




More information about the Catalyst mailing list