I created this controller named api, as seen in you video.
@request.restful()
def place():
def GET(id):
place = db.place(id)
return place.as_dict() if place else None
def POST(name, description):
return db.place.validate_and_insert(name = name, description =
description)
def PUSH(place,name):
db.place[place].update_record(name = name)
return dict()
#delete place by name
def DELETE(name):
del db.place(name)
return dict()
return locals()
when i call in url localhost/appname/api/place/1, it only makes the GET
method for the id=1 of the place, and then for the POST method i did this
script on the default controler:
def post():
import urllib
import urllib2
api_params = {
'name': request.args(0),
'description' : request.args(1),
}
http_response = urllib2.urlopen('http://localhost/api/place',
urllib.urlencode(api_params))
return http_response
I put this: http://localhost/appname/post/name_example/description_example
and it add another place with that name and that description.
And this script work perfectly. But i can not find any support for the
DELETE and PUSH methods. I think i will have to do another script, but i can
not find support about that on the web.