How to use HTTP DELETE method in Google App Engine?

I can use this verb in the Python Windows SDK. But not in production. What for? What am I doing wrong?

Error message includes (only through firebug or fiddler)

Invalid request

or something like that

My code looks like this:

from google.appengine.ext import db from google.appengine.ext import webapp class Handler(webapp.RequestHandler): def delete(self): key = self.request.get('key') item = db.get(key) item.delete() self.response.out.write(key) 
+7
python google-app-engine
source share
1 answer

Your handler looks fine, are you sure you are sending the request correctly? Using jQuery, this works for me (both using dev_appserver and using the Google engine):

 $('#delete-button').click(function() { $.ajax({ 'type': 'DELETE', 'url': '/some/url/that/handles/delete' }) }); class DeleteHandler(webapp.RequestHandler): def delete(self): if users.get_current_user() == allowed_user: the_data_model.delete() else: self.response.out.write('Permission denied') 

Sending the body of the response / message did not work for me (for example, the message "access denied" in my example will not be delivered to the client). Have you confirmed that your products are not deleted?

+3
source

All Articles