[Catalyst] Re: How to print/display some data in an end action
Matt S Trout
dbix-class at trout.me.uk
Mon May 5 12:04:59 BST 2008
On Wed, Apr 30, 2008 at 04:16:00PM +0200, 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';
Delete this line, your end action will already do it.
> $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);
Delete this one too, that's going to make end() be run twice.
> $c->forward('Root', 'end');
> }
Once you've fixed those, all you should need to do is make sure there's
something in $t and RenderView won't call the TT view at all for rg.
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list