On Mon, Nov 23, 2009 at 12:06 PM, Ross Vandegrift <[email protected]> wrote:
> On Mon, Nov 23, 2009 at 11:59:03AM -0800, Mike Orr wrote:
>> The answer is to use a generic 'id' variable in the route, and to
>> rename the variable in the action.  This is the philosophy behind the
>> default "/{controller}/{action}/{id}" route.
>>
>> map.connect("/api/{action}/{id}", controller="api")
>
> I thought about doing something like this, but this will break
> documentation generation: the parameters will all be generated in the
> docs as "id".  While I might be able to get over that, I have to
> publish this API to programmers that will (fairly) get confused when
> they see a funtion that takes an id, but the documentation claims it's
> something like a name.

Maybe.  The action name implies the nature of the ID.  And you have to
validate/convert the ID anyway, so 'id' is not necessarily the same as
'acct' or 'name'.  Action methods by definition take routing variables
as-is, so ``.get_byacct(self, id)`` is not necessarily bad.  You
should arguably have a separate set of business methods in the model
that take the real identifiers, to separate the business logic from
the HTTP UI (which is what the actions are).

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


Reply via email to