Re: [tornado] How to do RESTful DELETE in RequestHandler with parameters

1,436 views
Skip to first unread message

Phil Whelan

unread,
Sep 8, 2012, 6:34:57 PM9/8/12
to python-...@googlegroups.com
Hi Mrtn,

Can you give an example a type of parameters you would want to pass? I think this just comes from the REST spec, in which a DELETE is just a DELETE and nothing more.

Cheers,
Phil

On Sat, Sep 8, 2012 at 10:16 AM, mrtn <mrtn...@gmail.com> wrote:

I notice that there is a 'DELETE' method in RequestHandler, but wonder how you can pass parameters to it from the front-end.

It seems that JQuery ajax function does not support 'data' option with 'DELETE' or 'POST' requests, thus a feasible way is to append to a URL string: e.g. /stuff/delete/12345?para=blah. However, that is probably not RESTful.

So I wonder if there is a workaround for doing RESTful 'DELETE' request with parameters in Tornado. Thanks!

mrtn

unread,
Sep 9, 2012, 12:36:28 PM9/9/12
to python-...@googlegroups.com

Hi Phil,

Thanks for the clarification on REST. I've changed my design so that no extra parameters is needed for a DELETE request.

One related question though, is the term 'argument' the same as 'parameter' in Tornado? For example,

def delete(self, id):
    # id is an argument from /stuff/delete/[id here]

    # my_para is another argument from /stuff/delete/id?my_para=blah
    my_para = self.get_argument('my_para')

Roey Berman

unread,
Sep 9, 2012, 12:52:24 PM9/9/12
to python-...@googlegroups.com
Hi,

Use get_argument() to get arguments passed via POST or GET (or possibly other methods).
Similar to PHP's $_REQUEST variable.

The arguments you receive in the handler function (delete in your case) is the result of a regex match in the url path.

Hope this helps.

- Roey

Phil Whelan

unread,
Sep 9, 2012, 1:17:11 PM9/9/12
to python-...@googlegroups.com
On Sun, Sep 9, 2012 at 9:36 AM, mrtn <mrtn...@gmail.com> wrote:
is the term 'argument' the same as 'parameter' in Tornado?

I'm not sure. I use the terms interchangeably, but I do not know if there is a semantic difference in Tornado.

Phil
Reply all
Reply to author
Forward
0 new messages