2009年9月17日星期四

Re: [fw-mvc] Zend_Rest_Route recommendations; different views on same resource

-- Exception e <exceptione@hotmail.com> wrote
(on Wednesday, 16 September 2009, 03:29 PM -0700):
> Zend_Rest_Route has a very humble place in the documentation up to now.
> I was wondering what you've had in mind for the common case that you have a
> show and an edit action on a certain resource:
>
> Quoting a ruby on rails rest cheatsheet, this is how they do/did?
> differentiate between editing and showing a resource
>
> VERB: GET
> PATH: teams/1/players/3
> action: show
>
> VERB: GET
> PATH: teams/1/players/3;edit
> action: edit
>
>
> So what they basically do is saying that player 3 and 3;edit are different
> resources; they are different members of the same team.
>
> I can understand this reasoning, but I tend to think that we want to GET a
> different view on the same resource. This would mean that view is a concept
> in REST isolated from resource. I've read some articles and even parts of
> the original doctor's thesis, but I don't know.
>
> Maybe the designers from this component are real REST experts that can
> enlighten my humble mind? I don't have experience yet with REST, but I want
> to do it right, because there are many things called REST which aren't.

Zend_Rest_Route currently only handles top-level resources. I've created
a prototype that handles arbitrary depth hierarchies, and will be
submitting a proposal soon for review.

Part of this is also allowing arbitrary additional "actions" to be
appended to the resource (something that Zend_Rest_Route also supports).
Currently, those are added in the notation "/:action":

teams/1/edit

With the hierarchical rest route, you'd then be able to do this:

teams/1/players/3/edit

I can post code in a gist if necesary.

> For other people,
> http://www.atomenabled.org/developers/protocol/atom-protocol-spec.php#operation
> the atom-protocol is a good REST-example imho. It only doesn't offer me a
> practical answer for my question.
>
> // To be honest, I think that Zend_Rest_Server is a mistake with respect to
> its name. It has its use, but it's not REST.

This has been gone over umpteen times, if you look through the archives.
:)

We plan to deprecate Zend_Rest_Server in an upcoming release, now that
Zend_Rest_Route is in place. As you note, it's not ReSTful -- it's an
RPC implementation, and as such, should not be part of the distribution.

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: