web2py RESTful服务

时间:2013-09-16 19:23:24

标签: web-services http rest web2py

我正在尝试实现RESTful服务,如下所述: http://www.web2pyslices.com/slice/show/1533/restful-api-with-web2py

GET,PUT和POST按预期工作,但是DELETE没有。我得到了

 <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

任何想法?

1 个答案:

答案 0 :(得分:1)

调试后我发现问题是由vars解析函数引起的,该函数抛出异常。我在globals.py def restful(self)处添加了以下代码:

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

这解决了问题