Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

(no subject)

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


Jo.Kilian at gmx

Feb 28, 2012, 5:03 AM

Post #1 of 4 (277 views)
Permalink
(no subject)

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.

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?

Thanks in advance
Johannes
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

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


diment at gmail

Feb 28, 2012, 12:24 PM

Post #2 of 4 (265 views)
Permalink
Re: (no subject) [In reply to]

On 29/02/2012, at 12:03 AM, 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.
>
> 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?

I'd either use Catalyst::View;:Download::XML, or steal from it to create your own view: https://metacpan.org/module/Catalyst::View::Download::XML
_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


bobtfish at bobtfish

Feb 28, 2012, 4:32 PM

Post #3 of 4 (260 views)
Permalink
Re: (no subject) [In reply to]

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


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


billcrawford1970 at gmail

Feb 29, 2012, 2:35 AM

Post #4 of 4 (262 views)
Permalink
Re: (no subject) [In reply to]

On 28 February 2012 13:03, Johannes Kilian <Jo.Kilian [at] gmx> wrote:

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

$c->stash(current_view => '...');

Then override that either in an individual action or part of a chain ...

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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.