7

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) 
9
  • You say that you are seeing this in production, yes? What do the request logs say in the production admin console? There are a couple of possible exceptional conditions that your code is not handling, and if the code is crashing, you will see some information about it. Also, it would be very helpful to see the actual request that it being sent to AppEngine. Commented Mar 8, 2010 at 15:07
  • @Adam I have seen nothing in the admin console, just older errors. Commented Mar 8, 2010 at 15:48
  • It would appear, then, that the request isn't even making it all the way to the request handler, so that's not where the problem is. Can you post the actual request itself in the body of your question? Commented Mar 8, 2010 at 15:50
  • 4
    Are you sending a body in the DELETE request? The HTTP spec says DELETE should not have a body, and the production environment replicates that. Commented Mar 8, 2010 at 17:02
  • 3
    No, the HTTP spec does not say that, Nick, at least not in Section 9.7. Commented Mar 8, 2010 at 17:26

1 Answer 1

3

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?

Sign up to request clarification or add additional context in comments.

2 Comments

@JaderDias - No, this works because there is no request body sent in this example DELETE request.
This works. But you send a body the request not even reaches the server.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.