In GAE Python, I could use
class MyRequestHandler(webapp.RequestHandler):
def get(self):
pass #Do Something...
def post(self):
pass #Do Something...
To handle GET and POST request. But how can I handle DELETE and PUT? I see delete() and put() in API documentation, but I don't know how to write a form to simulate DELETE and PUT.
I know in Rails, I can use post method with a hidden field in form to simulate the requests like this:
<input type="hidden" name="_method" value="delete" />
and Rails handles the dirty works automatically.
Is there any similar way to do it in GAE python?
I searched this in Google, but no luck.
Thanks.
Deleting tasks from a queueClick the name of the queue from which you want to remove the task. Select the task that you want to delete and click Delete selected tasks. Click Delete.
App Engine calls the handler script with a Request and waits for the script to return; all data written to the standard output stream is sent as the HTTP response. There are size limits that apply to the response you generate, and the response may be modified before it is returned to the client.
Handling requests Any request can be routed to any instance, so consecutive requests from the same user are not necessarily sent to the same instance. An instance can handle multiple requests concurrently. The number of instances can be adjusted automatically as traffic changes.
The average length of time it takes to hear back is one to two weeks or around 10-14 days after you submit your application materials. In contrast, certain jobs, like those for government positions could take as long as six to eight weeks to hear back.
You can use the request method which accepts all the methods like get,post,delete and put. Then you can check it for the request type accordingly.
Check this:
http://gdata-python-client.googlecode.com/svn/trunk/pydocs/gdata.urlfetch.html
<form method="post" action="">
<input type="hidden" name="_method" value="put" />
<input type="text" name="name" value="" />
<input type="submit" value="Save" />
</form>
def post(self):
method= self.request.get("_method")
if method == 'put':
#call put() function as required
you can go through this as well for the put specification.
http://code.google.com/appengine/docs/python/tools/webapp/requesthandlerclass.html#RequestHandler_put
The HTML specification doesn't allow a form to use the DELETE method, and you probably can't get a browser to send an HTTP DELETE request with a form. The delete() method of a RequestHandler subclass would generally be used for a RESTful web application with a client that knows how to send DELETE requests, rather than using ordinary HTML forms. (For a browser-based client, you can send DELETE requests in javascript using XMLHttpRequest.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With