python - __init__() 恰好接受 1 个参数(给定 3 个)Google 应用引擎

标签 python google-app-engine google-cloud-messaging

我一直在上传我的 App Engine 应用程序的新版本,上传后当我发出请求时,我得到了这样的响应:

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

我完全不知道该怎么做,我注释了我的部分代码,取消了注释,我已经将代码上传到我拥有的不同 GAE 应用程序,甚至是这些应用程序的多个版本。

我什至不知道从哪里开始 谁能告诉我这个错误甚至意味着什么?我会提供您要求的任何信息,在此先感谢您。

编辑: 这是我添加的处理程序的样子:

class GCMRegister(webapp2.RequestHandler):
    def post(self):
        regid = self.request.get("regId")
        if not regid:
            self.response.out.write('Must specify regid')
        else:
            u = usuario()
            u.name = "deadlybacon" # ax_length = 140)
            u.mail = "testmail@hotmail.com" # (max_length = 256, db_index = True
            u.password = "password" #max_length = 140)
            u.put()
            u.push_key(regid)

我的 WSGIApplication 看起来像这样:

application = webapp2.WSGIApplication([
    ('/', MainPage),

    ('/indexData', indexData),
    ('/ajaxLogIn', ajaxLogIn),
    ('/createGroup', createGroup),
    ('/masterServices', masterServices),
    ('/groupInfo', groupInfo),
    ('/groupInviteTo', groupInviteTo),
    ('/acceptNotif', acceptNotif),
    ('/adventureCreate', createAdventure),  
    ('/adventureAppointTo', adventureAppointTo), 
    ('/addNewPrueba', addNewPrueba), 
    ('/listPoolPruebas', listPoolPruebas), 
    ('/addExistingPrueba', addExistingPrueba), 

    ('/gcm/register', GCMRegister),

]) #, debug=True, config = config)

一开始我以为是debug和config,所以才注释掉,没什么区别,不管怎样都会出现同样的错误

最佳答案

试试这个:

class HomeHandler(webapp2.RequestHandler):
    def __init__(self, request, response):
        self.initialize(request, response)
        ...

关于python - __init__() 恰好接受 1 个参数(给定 3 个)Google 应用引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26127164/

相关文章:

python - 使用 ctypes libc.strlen 时总是返回 1?

python - Othello Alpha-Beta Pruning 玩得很厉害 python

python - 如何扩展 Numpy 数组以包含每个条目的 x 个以下数字

python - 在没有 HTML 的情况下在 GAE 上提供 index.py?

python - 将 scikit-learn DecisionTreeClassifier.tree_.value 映射到预测类

django - App Engine/Django - 交错多个请求干扰 GAE session

python - 如何转换 Google AppEngine db.TimeProperty 中的时间字符串?

java - 推送通知模块发送 null

android - 拦截所有 GCM 推送消息(适用于任何应用程序)

android - 如何在应用程序卸载时从服务器中删除数据库记录