2012-07-30 36 views
1

我下載了appengine-rest-server(1.0.6)並嘗試在我的應用中使用此模塊,但出現一些錯誤。有沒有人用Python 2.7.2的工作示例?appengine-rest-server Python 2.7示例

按照我的代碼initalize模塊:

rest.Dispatcher.base_url = '/rest' 
rest.Dispatcher.add_models({ 
    "customer": customer.customer, 
    "place": customer.place}) 
application = webapp.WSGIApplication([<Some other Routs> , 
            ('/rest/.*', rest.Dispatcher)], debug=True) 

我得到這個錯誤:

File "\src\rest\__init__.py", line 1551, in initialize 
    request.disp_query_params_ = None 
AttributeError: 'NoneType' object has no attribute 'disp_query_params_' 

也許它是我的錯?

+0

你用'python2.6'試過了嗎? – 2012-07-30 11:20:32

+0

不幸的是,谷歌只提供Python 2.3和2.7。整個應用基於2.7,模塊有效。 – 2012-07-30 13:40:05

回答

0

修改以下功能,它似乎工作。

def initialize(self, request, response): 
     if request != None and response != None: 
      super(Dispatcher, self).initialize(request, response) 
      request.disp_query_params_ = None 
      response.disp_cache_resp_ = True 
      response.disp_out_type_ = TEXT_CONTENT_TYPE 
+0

對不起,1.0.6版本打算與2.7兼容,但顯然它並不完全。 1.0.7版本應該與python 2.7兼容。 – jtahlborn 2012-10-18 02:15:44