On Apr 2, 2006, at 4:10 PM, Ben Bangert wrote:

These are merely decorators on the actions being called in the Controller. They have no tie-in to routing.py at all. The dispatch_on is essentially just wrapping up the if/then logic you were talking about earlier into a generic controller. Routes works as normal, and if you want to change the action depending on an HTTP verb, you put that in the decorator.

Gotcha. Thanks.

In the case of restrict, it would throw a 404. If you wanted instead of restricting, to have something else happen, you'd use dispatch_on decorator.

Hmm, I don't think it should be 404, it should be 405:

10.4.6 405 Method Not Allowed

The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource. 

(No reason we can't write code to build the Allow header explicitly, based on the decorator value...)

Does this suggest that @pylons.rest.restrict() should take a list?

@pylons.rest.resrict("POST", "PUT"), so any other method returns a 405 with an Allow: header of POST, PUT:

HTTP/1.1 405 Method Not Allowed
Allow: POST, PUT

Yeah?

And, FWIW, I think I prefer @pylons.rest.dispatch() to dispatch_on(), but that's up to you.

So Routes continues to handle just the URL recognition, and you alter action dispatching using the decorator. Personally, just looking at it... I like it.

Yes, I do too. But I think restrict should take multiple methods.

It has the explictness of action mapping you like, and it doesn't require me to be flipping to routing.py to see where things are going, since the decorator makes it very clear what will change the action dispatch.

Yeah, fair enough.

So overall with this approach, we're only one away from what I think would be your ideal situation. That is, you're still stuck with a "default" action regardless of HTTP verb. Or does this cover your situation in a satisfactory manner?

Right now, today, that doesn't bother me. :>

Cheers,
Kendall



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to