Thanks Jay.

I thought of that solution too when I had a look at 
Catalyst::Plugin::Static::Simple. But in this case, my doubt was, and is, how 
should I create the view through the helper?
Most of the examples for creating views are TT views, so they create it as 
'script/hello_create.pl view my_TT_view TT'.
 David




________________________________
De: J. Shirley <[email protected]>
Para: The elegant MVC web framework <[email protected]>
Enviado: vie,5 marzo, 2010 16:45
Asunto: Re: [Catalyst] Best practices: XML output from static XML

On Fri, Mar 5, 2010 at 5:10 AM, David <[email protected]> wrote:
> Hi,
>
> I need to generate an XML output (Content-type: application/xml), but this
> XML output is the XML content which is stored in an XML file. I don't need
> to dinamically generate this XML content.
> I have searched in google but I don't find any catalyst view module for
> managing this case. I don't know if exists any module for generating XML
> output from a static file as, for example, Catalyst::View::XSLT module
> (http://search.cpan.org/~janus/Catalyst-View-XSLT-0.08/lib/Catalyst/View/XSLT.pm)
> does. That is, generate an output from a static file, in this case, an XML
> output.
>
> I am not finding much information about designing your own views in
> Catalyst, or at least, I don't see much flexibility. All examples I have
> found need to be generated, through the helper view, with TT template or any
> other templates.
> Is it possible to create your own view, with no template, and for example,
> in my case, read the output from a static file and send this output to the
> client? (I don't know exactly how Views works in Catalyst, though I have
> already read Catalyst tutorial and cookbook)
>
> Thanks in advanced,
>
>
> David
>


Well, you could do your own view or just rely on
Catalyst::Plugin::Static::Simple:

http://search.cpan.org/~mstrout/Catalyst-Plugin-Static-Simple-0.29/lib/Catalyst/Plugin/Static/Simple.pm#serve_static_file_$file_path

You could wrap this in a view:

package MyApp::View::StaticFile;

use parent 'Catalyst::View';

sub process {
    my ( $self, $c ) = @_;
    $c->serve_static_file( $c->stash->{static_file} );
}

1;



Then just do $c->forward( $c->view('StaticFile') ); after setting the stash key.

-Jay

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/



      
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to