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.

For the extension mapping, I was just going to do something like this in
my begin before deserialization happens:

  $c->request->content_type(
    MIME::Types->new->mimeTypeOf($c->flavour)
  ) if $c->flavour;

I'll have to add some missing mime-type, but that's no biggie.

In the end, this seems to be a struggle between content-types, views,
and/or rest. They're all nice, just all unattached from each other.

Well, part of it is that I wrote C::A::REST with my own requirements in mind. Which was primarily that it would be a "pure" REST service, without really having a useful TT style view. I knew that this would be an issue, so I tried to write it in a way that extending it would be pretty easy. I think adding a C::A::Serialize::View is the right idea.

Is there a better way?

I think we could probably put the functionality provided by Flavour directly into the loading of the Serializer in C::A::REST, essentially adding in the MIME::Type lookup based on the file extension.

I'm ridiculously busy until early in March. I would love to put some feedback into what you are doing, and patches would be warmly welcomed. :)

I'm on IRC most of the day; feel free to ping me in #catalyst or #catalyst-dev.

Adam (holoway)





_______________________________________________
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