2012-02-19 79 views
0

我试图设置一个使用谷歌应用程序引擎蟒2.7的protorpc服务,并且据我记得,这工作正常直到它突然停止工作,现在我无法弄清楚发生了什么问题。谷歌应用程序引擎Python Protorpc错误:__call __()需要刚好1个参数(3给出)

错误:

__call__() takes exactly 1 argument (3 given) 
Traceback (most recent call last): 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__ 
    rv = self.handle_exception(request, response, e) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__ 
    rv = self.router.dispatch(request, response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher 
    return route.handler_adapter(request, response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1040, in __call__ 
    return self.handler(request, *args, **kwargs) 
TypeError: __call__() takes exactly 1 argument (3 given) 

Traceback (most recent call last): 
    File "/base/data/home/apps/s~smokin-goldshop/15.356936819989737198/handler/orderajax.py", line 78, in main 
    util.run_wsgi_app(application) 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app 
    run_bare_wsgi_app(add_wsgi_middleware(application)) 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/util.py", line 116, in run_bare_wsgi_app 
    result = application(env, _start_response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1519, in __call__ 
    response = self._internal_error(e) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__ 
    rv = self.handle_exception(request, response, e) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__ 
    rv = self.router.dispatch(request, response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher 
    return route.handler_adapter(request, response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1040, in __call__ 
    return self.handler(request, *args, **kwargs) 
TypeError: __call__() takes exactly 1 argument (3 given) 

代码的问题:

import logging 
from google.appengine.ext import webapp 
from google.appengine.ext.webapp import util 

from protorpc import messages 
from protorpc import remote 
from protorpc import service_handlers 
from protorpc.service_handlers import ServiceHandlerFactory 

from customerhandler import CustomerHandler 
from models.customer import Customer 


class BlacklistRequest(messages.Message): 
    BlackListType = messages.StringField(1, required = True) 
    Customer = messages.StringField(2, required = True) 

class BlacklistResponse(messages.Message): 
    Response = messages.StringField(1, required = True) 

class BlacklistAjax(remote.Service): 
    @remote.method(BlacklistRequest, BlacklistResponse) 
    def ajax(self, request): 
     logging.debug("starting") 
     tRequest = request 
     logging.debug(str(tRequest)) 
     tArgumentDic = {} 
     tCustomerHandler = CustomerHandler() 
     tCustomer = Customer() 
     logging.debug("Beginning Blacklist of type " + tRequest.BlackListType + " for customer " + tRequest.Customer) 

     if(tRequest.BlackListType == 'PA'): 
      tCustomerHandler.PaBlacklistCustomer(tRequest.Customer) 
      logging.debug("Blacklisted PA") 
      return BlacklistResponse(Response = "PA Blacklisted!") 
     elif(tRequest.BlackListType == 'Global'): 
      tCustomerHandler.GlobalBlacklistCustomer(tRequest.Customer) 
      logging.debug("Blacklisted Global") 
      return BlacklistResponse(Response = "Global Blacklisted!") 
     else: 
      logging.debug("Error Blacklisting") 
      return BlacklistResponse(Response = "Error Blacklisting") 



service_mappings = service_handlers.service_mapping(
    [('/orderajax', OrderAjax), 
    ('/blacklist', BlacklistAjax) 
    ]) 

application = webapp.WSGIApplication(service_mappings, debug=True) 

def main(): 
    util.run_wsgi_app(application) 

if __name__ == '__main__': 
    main() 

回答

2

敲我的头靠在我的办公桌上了几次后,我做了一些挖,发现如下:

简答

看来webapp2模块不支持当前时间为,反之亦然。使用protorpc的唯一方法是切换到webapp模块,而不是webapp2在这种情况下,你还需要恢复的Python 2.5和app.yaml设置threadsafe为false,例如:

# -- snip -- 
runtime: python25 
threadsafe: false 
# -- /snip -- 

长的答案

http://code.google.com/p/webapp-improved/issues/detail?id=16在该项目的维护者(罗德里戈·赖斯)说:

2011年9月17日

I've been thinking on the subject and the best would be probably to remove webapp2_extras.protorpc. It is only usable with the 2.5 runtime, and has no reason to exist when webapp2 replaces webapp: it is protorpc that needs to support webapp2 in the 2.7 runtime, as it it did with webapp.

二○一一年十一月十日

I believe the ProtoRPC project should provide a way.

The webapp2_extras.protorpc package will be removed as it makes no sense to maintain it anymore.

2012年1月24日

webapp2_extras.protorpc was removed from version 2.4.

I'd like to support this but there's a bit too much magic involved, so better to have it as a separated, actively maintained project (or if protorpc project supports it by default).

因此,一个问题一直在请求webapp2支持ProtoRPC的项目被打开:http://code.google.com/p/google-protorpc/issues/detail?id=38

+0

所以我怀疑即使在发布“全力支持”的情况下蟒蛇2.7,这仍然是坏的?你的回答将解释为什么当我升级版本时代码停止工作... – 2012-03-01 00:11:55

+0

我不知道他们有2.7的支持?或者你的意思是2.7支持GAE而不是webapp2?如果你的意思是webapp2,那么是的,它仍然是坏的。 webapp2维护者认为protorpc需要支持2.7。 – Cale 2012-03-01 04:51:22

+1

我的意思是GAE 2.7支持。我已经构建了一个定制的ajax系统,所以我不再需要protorpc。感谢您的帮助,并恭喜您的第一个接受的答案。 – 2012-03-01 22:53:14

相关问题