Django / App Engine / Python 2.5:默认__new__不带参数

时间:2010-03-04 07:53:27

标签: python django google-app-engine

app引擎和django新手。我认为这是我的django安装的问题,这是1.1.1,但我也读过我可以使用与app引擎SDK一起打包的django。

当我在本地测试时,为什么我收到此错误的任何帮助都将非常感谢。

回调:

Variable Value
callback 
<class 'ourlat.main.views.SettingsPage'>
callback_args 
()
callback_kwargs 
{}
e 
TypeError('default __new__ takes no parameters',)
exc_info 
(<type 'exceptions.TypeError'>, TypeError('default __new__ takes no parameters',), <traceback object at 0x02201B48>)
exceptions 
<module 'django.core.exceptions' from 'C:\Documents and Settings\Jeremy Gordon\eclipse-workspace\ourlat\django\core\exceptions.pyc'>
middleware_method 
<bound method CommonMiddleware.process_request of <django.middleware.common.CommonMiddleware object at 0x021F5170>>
receivers 
[(<function _rollback_on_exception at 0x02063730>, None)]
request 
<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{}, META:{'APPLICATION_ID': 'ourlat', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'localhost:8080', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.1 (KHTML, like Gecko) Chrome/5.0.335.1 Safari/533.1', 'PATH_INFO': u'/', 'PATH_TRANSLATED': 'C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat\\main.py', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': u'', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SOFTWARE': 'Development/1.0', 'TZ': 'UTC', 'USER_EMAIL': '', 'USER_ID': '', 'USER_ORGANIZATION': '', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x00B1F0B0>, 'wsgi.input': <cStringIO.StringI object at 0x022A0260>, 'wsgi.multiprocess': False, 'wsgi.multithread': False, 'wsgi.run_once': True, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
resolver 
<RegexURLResolver urls (None:None) ^/>
response 
None
self 
<django.core.handlers.wsgi.WSGIHandler object at 0x021F5790>
settings 
<django.conf.LazySettings object at 0x01E997B0>
urlconf 
'urls'
urlresolvers 
<module 'django.core.urlresolvers' from 'C:\Documents and Settings\Jeremy Gordon\eclipse-workspace\ourlat\django\core\urlresolvers.pyc'>

错误:

TypeError at /
default __new__ takes no parameters
Request Method: GET
Request URL: http://localhost:8080/
Exception Type: TypeError
Exception Value: 
default __new__ takes no parameters
Exception Location: C:\Documents and Settings\Jeremy Gordon\eclipse-workspace\ourlat\django\core\handlers\base.py in get_response, line 92
Python Executable: C:\Python25\python.exe
Python Version: 2.5.0
Python Path: ['C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat', 'C:\\Program Files\\Google\\google_appengine', 'C:\\Program Files\\Google\\google_appengine\\lib\\antlr3', 'C:\\Program Files\\Google\\google_appengine\\lib\\django', 'C:\\Program Files\\Google\\google_appengine\\lib\\ipaddr', 'C:\\Program Files\\Google\\google_appengine\\lib\\webob', 'C:\\Program Files\\Google\\google_appengine\\lib\\yaml\\lib', 'C:\\Program Files\\Google\\google_appengine', 'C:\\Python25\\lib\\site-packages\\beautifulsoup-3.1.0.1-py2.5.egg', 'C:\\Python25\\lib\\site-packages\\django-1.1.1-py2.5.egg', 'C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat\\ourlat', 'C:\\Program Files\\Google\\google_appengine', 'C:\\Program Files\\Google\\google_appengine\\lib\\webob', 'C:\\Program Files\\Google\\google_appengine\\lib\\yaml', 'C:\\Program Files\\Google\\google_appengine\\lib', 'C:\\Program Files\\Google\\google_appengine\\lib\\simplejson-2.0.9', 'C:\\Program Files\\Google\\google_appengine\\lib\\geopy', 'C:\\Program Files\\Google\\google_appengine\\lib\\BeautifulSoup-3.0.8', 'C:\\Documents and Settings\\Jeremy Gordon\\eclipse-workspace\\ourlat\\django', 'C:\\Python25', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\setuptools-0.6c7-py2.5.egg', 'C:\\Python25\\lib\\site-packages\\simplejson-2.0.9-py2.5.egg', 'C:\\Python25\\Lib\\site-packages\\geopy-0.93dev_r0-py2.5.egg', 'C:\\WINDOWS\\system32\\python25.zip']
Server time: Sat, 6 Mar 2010 01:18:27 +0000

设置页面来源

class SettingsPage(webapp.RequestHandler):
    def get(self):
        if users.get_current_user():
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
            account_query = OLAccount.all().filter('owner =',users.get_current_user())
            if account_query.count() < 1:
                thisuser = OLAccount(owner = users.get_current_user())
                thisuser.put()
            else:
                thisuser = account_query.fetch(1)[0]

            tracks = [db.get(key) for key in thisuser.track_keys] 
            template_values = {
                'url': url,
                'url_linktext': url_linktext,
                'thisuser': thisuser,
                'tracks': tracks
                }

            path = os.path.join(os.path.dirname(__file__), 'html/settings.html')
            self.response.out.write(template.render(path, template_values))
        else:
            self.redirect(users.create_login_url(self.request.uri))

1 个答案:

答案 0 :(得分:2)

您似乎已经使用非标准签名的__init__(但不是__new__)将Django的视图类子类化(至少一次)。如果你点击这条消息开头的三角形(在你自己的环境中 - 点击对SO中的这个拷贝/粘贴的msg不起作用,当然;-)你应该看到局部变量,包括例如callback这是您要调用的视图(来自您的网址解析程序,请参阅第68行的the source) - 此信息有助于进一步调试。

编辑:看起来问题是你正在混合和匹配Django的urlresolvers(希望Django-id callables,将请求作为参数)与Google的{{1}的子类}(不接受webapp.RequestHandler中的参数):不要这样做。使用__init__选择app.yaml脚本处理对应用中每组路径的请求,并在每个.py脚本中仅使用Django或仅使用webapp - 不混合。

顺便说一下,应用引擎SDK附带的Django是0.96,就像google服务器上的默认值一样;但是在google的服务器上,您可以使用use_library轻松切换到更现代版本的django,而在SDK上则不能 - 也就是说,不能在本地安装自己的django&amp; c。请参阅我刚刚指出的页面并从中链接。