Adam Jacob wrote:
> On Jan 29, 2007, at 12:19 PM, Christopher H. Laco wrote:
> 
>> Christopher H. Laco wrote:
>>> I'm needing to support RSS/Atom feeds of some of my cart/wishlist data.
>>> The lazy guy in me says I can just make a view or two and be done with
>>> it (Thanks for the code LTjake!). The anal retentive programmer in me
>>> says I probably really want to use C::A::REST to get the benefit of
>>> mime-type request mapping and de/serialization for other things that
>>> might come along, like json/yaml.
> 
> Adding RSS/Atom is, as you say, just adding a proper serialization class
> for the data.
> 
>>> On top of that, I want things to also work by extension: .json, .atom,
>>> .rss etc. That's where C::P::Flavour enters the picture.
> 
> I thought about that.  I have never seen Catalyst::Plugin::Flavour (it
> doesn't look like it has a CPAN release, nor is it in the Catalyst
> repo.)  Currently, C::A::REST supports using a content-type argument on
> GET requests to over-ride the serializer.  It would be pretty simple to
> just add the logic for the extension mapping to work as well
> 
>>> As it stands now, REST JustWorks with xml/json stuff. text/html is
>>> mapped to YAML::HTML, but I want to map that to my standard TT view. As
>>> for RSS/Atom, I'd need a Serializer for them, which in the end isn't
>>> really different than writing a view.
> 
> I think you nail that problem lower down.  We should totally make a
> C::A::Serialize::View.

Yeah, I eeked this out yesterday while tinkering with the idea:

> package Catalyst::Action::Serialize::View;
> use strict;
> use warnings;
> 
> BEGIN {
>     use base 'Catalyst::Action';
> };
> 
> sub execute {
>     my $self = shift;
>     my ($controller, $c, $view) = @_;
>     my $stash_key = $controller->config->{'serialize'}->{'stash_key'} || 
> 'rest';
> 
>     if (!$c->view($view)) {
>         $c->log->debug("Could not load $view, refusing to serialize");
>         return 0;
>     };
> 
>     return $c->view($view)->process($c);
> };
> 
> 1;


There are still some issues with using views, mainly that they both
fight of setting content-type...and since REST sets it already, the view
never sets it, which is good, but also the charset=utf isn't set either...

Once I get something more solid, I'll post what I have.

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to