Search code examples
web-serviceshttprestweb2py

web2py RESTful service


I'm trying to implement a RESTful service as explained here: http://www.web2pyslices.com/slice/show/1533/restful-api-with-web2py

GET, PUT and POST work as expected, but DELETE doesnt. I get

 <type 'exceptions.TypeError'> not indexable

web2py™ Version 
 2.6.3-stable+timestamp.2013.09.15.17.01.20
Python  Python 2.7.4: /usr/bin/python (prefix: /usr)  
Traceback (most recent call last):  
  File "../gluon/restricted.py", line 217, in restricted  
    exec ccode in environment  
  File "../applications/app/controllers/default.py", line 103, in <module>  
  File "../gluon/globals.py", line 378, in <lambda>  
    self._caller = lambda f: f()  
  File "../gluon/globals.py", line 348, in f  
    raise e  
TypeError: not indexable

any ideas?


Solution

  • After debugging I found out the problem is caused by the vars parsing function, which throws an exception. I added the following code in globals.py at def restful(self) :

    if rest_action.func_name == 'DELETE':
        return  rest_action(*_self.args)
    

    This solved the problem