On Mon, May 7, 2012 at 8:44 AM, Jonathan Vanasco <[email protected]> wrote:
> i generally hate this approach to web programming.
>
> i find it very shortsighted and unmanageable for those you're trying
> to service - if you change your website, the API more often than not
> causes apps to break.

I wouldn't go as far as saying I "hate" this approach, but the fact
remains that the interactive UI will inevitably require features that
the web-service API doesn't, such as additional data variables for
presentation features, or paging through the results. For the case of
extra variables (undesired in JSON), you can set them as instance
variables in the view (available in templates as 'view.*').

Routes has a feature where if you append a suffix to a Resource URL
(as in ".xml" or ".json"), the suffix would be passed to the action
via the 'format' routing variable. This may have followed a Rails/Atom
precedent. But whenever I tried to use it, I found that there were so
many other differences in generating HTML vs generating XML or JSON
that it was better to have separate actions for them. Also, it's not
very common to provide multiple formats for every URL, so many times
there was just no valid XML format I was willing to generate.

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to