durusmail: quixote-users: non-idempotent GETs
non-idempotent GETs
2005-05-10
2005-05-10
2005-05-10
2005-05-10
2005-05-10
2005-05-11
2005-05-10
2005-05-10
2005-05-10
2005-05-29
2005-05-29
2005-05-29
non-idempotent GETs
Ryan Tomayko
2005-05-10
On May 9, 2005, at 11:44 PM, Titus Brown wrote:
> -> I guess Quixote could provide a utility function if the link_to
> idea
> -> catches on.
>
> It might be worth mentioning it somewhere in the docs.  Certainly I've
> found that the 'object/delete' functionality is, umm, too obvious
> not to
> use ;).

No rule that says you can't use 'object/delete', just make sure you
use POST and not GET when you do. Here is some code that might help
(code not tested):

     class MethodNotAllowedError(PublishError):
         status_code = 405
         title = "Method not allowed"
         description = ("The method specified in the Request-Line is
not allowed "
                        "for the resource identified by the Request-
URI.")
         def __init__(self, allowed_methods):
             PublishError.__init__(self)
             get_response().set_header('Allow', ', '.join
(allowed_methods))

     class Whatever(Directory):
         _q_exports = ['delete']
         def delete(self):
             if get_request().get_method() != 'POST':
                 raise MethodNotAllowedError(['POST'])
             # do delete

Ideally, proper verb use, content negotiation, and other fundamental
aspects of HTTP would be handled by the object publishing framework.
Unfortunately, I'm at a loss for exactly how that might be
implemented cleanly, and not for lack of thinking about it...

Ryan Tomayko
                                  rtomayko@gmail.com
                                  http://naeblis.cx/rtomayko/


reply