[Catalyst] (no subject)

Tomas Doran bobtfish at bobtfish.net
Wed Feb 29 00:32:21 GMT 2012


On 28 Feb 2012, at 13:03, Johannes Kilian wrote:

> Hi,
> 
> I've got following question concerning views: I want to provide an XML-View which provides "standard" XML-Files using XML::Simple in almost any case. Just in some cases I want to provide specialized XML-Files.

Erm, why are you not just sending your already rendered "standard" XML file?

I.e. what is the point in using XML::Simple at all here - why not just set the body?

> In other words: I want to use XML::Simple as default handler - which is overriden by a specialized XML Generator in some cases ...
> 
> Within my controller I do have something like this:
> ----
> __PACKAGE__->config(
>  'default'   => 'text/html',
>  'stash_key' => 'rest',
>  'map'       => {
>    'text/html' => [ 'View', 'TT', ],
>    'text/xml'  => [ 'View', 'XML', ],
>    #    'text/xml'           => 'XML::Simple',
>  }
> );
> -----
> 
> I cannot figure out how to set XML::Simple as default handler and override this for certain URLs within the same controller whilst for other URLs within the same controller the default XML-Handler is used ....
> 
> Is this possible at all?
> How can I do this?

Erm, what do you mean by 'XML handler' here?

XML::Simple will serialise whatever data structure you give it (as per any of the other serialisation methods!).. So just give it a different data structure in the different cases?

Alternatively - if you really want to _totally_ override it, just set the response body manually, and the Controller::REST end action will leave it alone..

Cheers
t0m




More information about the Catalyst mailing list