Google App Engine Python Protorpc错误:__call __()只需要1个参数(给出3个参数) [英] Google App Engine Python Protorpc Error: __call__() takes exactly 1 argument (3 given)

查看:101
本文介绍了Google App Engine Python Protorpc错误:__call __()只需要1个参数(给出3个参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用谷歌应用程序引擎python 2.7建立一个protorpc服务,并且据我记得,这工作正常,直到它突然停止工作,现在我无法弄清楚什么是错误的。



错误:

  __ call __()只需要1个参数(3给出)
Traceback(最近一次调用最后一次):
文件/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1511行,在__call__
rv = self.handle_exception(request,response,e)
在__call__
rv = self文件中的/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1505行。 router.dispatch(请求,响应)
文件/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1253行,在default_dispatcher
返回route.handler_adapter(request,响应)
文件/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1040行,在__call__
返回self.handler(request,* args,** kwargs )
TypeError:__call __()只需要1个参数(给出3个)

追踪(最近一次调用最后一个):
文件/ base / data / home / apps / s 〜戒掉-GOL dshop / 15.356936819989737198 / handler / orderajax.py,第78行,在主
util.run_wsgi_app(应用程序)
文件/ base / python27_runtime / python27_lib / versions / 1 / google / appengine / ext / webapp /util.py,第98行,在run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(应用程序))
文件/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/util.py ,第116行,在run_bare_wsgi_app
result = application(env,_start_response)
文件/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1519行,在__call__中
response = self._internal_error(e)
文件/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,第1511行,在__call__
rv = self .handle_exception(request,response,e)
在__call__
rv = self.router中的文件/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py,行1505。调度(请求,响应)
文件/ bas e / python27_runtime / python27_lib / versions / third_party / webapp2-2.3 / webapp2.py,第1253行,在default_dispatcher
返回route.handler_adapter(request,response)
文件/ base / python27_runtime / python27_lib /版本/ third_party / webapp2-2.3 / webapp2.py,第1040行,在__call__
返回self.handler(request,* args,** kwargs)
TypeError:__call __()只需要1个参数3给出)

有问题的代码:

 从google.appengine.ext导入日志记录
从google.appengine.ext.webapp导入webapp
从protorpc导入消息导入util


from protorpc进口远程
from protorpc import service_handlers $ b $ from protorpc.service_handlers import CustomerHandlerFactory

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)
$ b $ 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 =请求
logging.debug(str(tRequest))
tArgumentDic = {}
tCustomerHandler = CustomerHandler()
tCustomer = Customer()
logging。 (tRequest.BlackListType =='PA'):
tCustomerHandler.PaBlacklistCustomer(tRequest.Customer)的调试(开始黑名单类型为+ tRequest.BlackListType +for customer+ tRequest.Customer)

tRequest.Customer)
logging.debug(Blacklisted PA)
return BlacklistResponse(Response =PA Blacklisted!)
elif(tRequest.BlackListType =='Global'):
tC ustomerHandler.GlobalBlacklistCustomer(tRequest.Customer)
logging.debug(Blacklisted Global)
return BlacklistResponse(Response =Global Blacklisted!)
else:
logging.debug( 错误黑名单)
返回BlacklistResponse(响应=错误黑名单)



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

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

def main():
util.run_wsgi_app(应用程序)
$ b $如果__name__ =='__main__':
main()


解决方案

在我的桌子上敲了几下我的桌子后,我做了一些挖掘并找到了以下内容:



短回答



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

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



长答案



http://code.google.com/ p / webapp-improved / issues / detail?id = 16 ,其中项目维护者(Rodrigo Moraes)表示:

2011年9月17日


我一直在想这个问题,最好的可能是
删除webapp2_extras.protorpc。它仅适用于2.5
运行时,并且在webapp2替换webapp时没有理由存在:
是需要在2.7运行时支持webapp2的protorpc,因为它是
所做的

2011年11月10日 $ b


我相信ProtoRPC项目应该提供一种方式。



webapp2_extras.protorpc软件包将被删除,因为它没有
的意义以保持它。


2012年1月24日


webapp2_extras.protorpc已从版本2.4中删除。

我想支持这个,但是有太多的魔力,所以
更好地将它作为一个单独的,主动维护的项目(或者if


因此在protorpc项目中打开了一个问题,它要求 webapp2 支持: http: //code.google.com/p/google-protorpc/issues/detail?id=38


I'm trying to set up a protorpc service using google app engine python 2.7, and as far as I can remember, this was working fine until it suddenly stopped working and now I can't figure out what's going wrong.

Error:

__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)

Code in question:

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()

解决方案

After banging my head against my desk several times, I did some digging and found the following:

Short Answer

It appears that the webapp2 module does not support protorpc at the current time or vice versa. The only way to use protorpc is to switch to the webapp module instead of webapp2 in which case you also need to revert to Python 2.5 and set threadsafe to false in app.yaml, eg:

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

Long Answer

http://code.google.com/p/webapp-improved/issues/detail?id=16 in which the project maintainer (Rodrigo Moraes) states:

Sep 17, 2011

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.

Nov 10, 2011

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.

Jan 24, 2012

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).

Therefore an issue has been opened in the protorpc project which requests webapp2 support: http://code.google.com/p/google-protorpc/issues/detail?id=38

这篇关于Google App Engine Python Protorpc错误:__call __()只需要1个参数(给出3个参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆