On Wed, Nov 12, 2008 at 9:44 PM, Mike Orr <[EMAIL PROTECTED]> wrote:
>
> On Wed, Nov 12, 2008 at 2:00 AM, mario ruggier <[EMAIL PROTECTED]> wrote:
>>
>> I would like to support specific http verbs on a given URI. For example, to
>> support GET and PUT for the URI /controller/action/id I have defined these
>> 2 dedicated routes:
>>
>> map.connect('/controller/action/:id', controller='controller',
>> action='GET_action', conditions=dict(method=['GET']))
>> map.connect('/controller/action/:id', controller='controller',
>> action='PUT_action', conditions=dict(method=['PUT']))
>>
>> Issuing a GET or PUT for this (same) URI will cause the correct action to
>> be executed... however, if I issue a request with a different method, such
>> as a POST, the response is a 500 Internal Server Error. I would have
>> expected a 404 Not Found, as is normally returned for "no matching route".
>>
>> A simple workaround (amongst other more elaborate -- and imho more
>> convoluted -- local dispatching mechanisms) is to follow up the above
>> routes with a catchall for the any other verbs:
>>
>> map.connect('/controller/action/:id', controller='controller',
>> action='OTHER_action')
>>
>> that would then be supplied as a method on controller simply to return 404:
>>
>> def OTHER_action(self, id):
>> abort(404)
>>
>> So, why the 500 and not the 404 in the first place?
>> Any other suggestions of how best to handle such situations?
>
> It should be 404 and it usually is. There must be a bug in how it
> processes the particular argument combination. What happens if you
> comment out the second route and remove the condition in the first?
If I do that then both GET and PUT (and all other verbs) requests are
routed to GET_action.
If (from the initial routes above) I instead comment out the PUT and
OTHER routes altogether (leaving the GET with its condition) and then
I request a PUT on same URI, the server responds with a 500:
NotImplementedError: Action u'action' is not implemented.
m.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---