Question

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

The error message includes (only seen via firebug or fiddler)

Malformed request

or something like that

My code looks like:

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)
Was it helpful?

Solution

Your handler looks OK, are you sure you're sending the request correctly? Using jQuery, this works for me (both using dev_appserver and google app engine production):

$('#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 a response body/message did not work for me (e.g. the "permission denied" message in my example won't get to the client). Have you verified your items aren't deleted?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top