TurboGears 2 快速入门立即显示错误
我是 TurboGears 的新手,刚刚在虚拟环境中安装了 TG2 开发。我按照 快速入门指南 进行操作,并通过以下方式成功构建了 helloworld
paster quickstart
我启动了服务器并将网络浏览器导航到 localhost:8080
你不知道吗,我立即收到一个错误,而不是文档建议我应该看到的欢迎消息。
错误内容如下:
AttributeError: 'AcceptLanguage' object has no attribute 'best_matches'
这是跟踪:
URL: http://localhost:8080/
File 'C:\\VirtualEnv_1\\lib\\site-packages\\weberror-0.10.3-py2.7.egg\\weberror\\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\beaker-1.6-py2.7.egg\\beaker\\middleware.py', line 73 in __call__
return self.app(environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\beaker-1.6-py2.7.egg\\beaker\\middleware.py', line 155 in __call__
return self.wrap_app(environ, session_start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\routes-1.12.3-py2.7.egg\\routes\\middleware.py', line 131 in __call__
response = self.app(environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\wsgiapp.py', line 107 in __call__
response = self.dispatch(controller, environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\wsgiapp.py', line 312 in dispatch
return controller(environ, start_response)
File 'C:\\VirtualEnv_1\\Scripts\\HelloWorld\\helloworld\\lib\\base.py', line 27 in __call__
return TGController.__call__(self, environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 211 in __call__
response = self._dispatch_call()
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 162 in _dispatch_call
response = self._inspect_call(func)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 105 in _inspect_call
result = self._perform_call(func, args)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\turbogears2-2.1.3-py2.7.egg\\tg\\controllers\\dispatcher.py', line 230 in _perform_call
setup_i18n()
File 'C:\\VirtualEnv_1\\lib\\site-packages\\turbogears2-2.1.3-py2.7.egg\\tg\\i18n.py', line 61 in setup_i18n
pylons.request.accept_language.best_matches())) AttributeError: 'AcceptLanguage' 对象没有属性 'best_matches'
我安装它时是否搞砸了一些东西,或者这是 TurboGears 的问题?
编辑:我创建了第二个项目,名为 GoodnightMoon,这次没有 Mako 模板选项(这是设置之间的唯一区别),并且我得到了相同的错误:
'AcceptLanguage' object has no attribute 'best_matches'
不幸的是,这个问题是我能找到的唯一一个 网络搜索与此错误完全相关。
我可以使用并向 stackoverflow 提供任何其他线索来帮助回答这个问题吗?
按照下面 Michael Pederson 的建议,我研究了 i18n。我有一个 i18n 目录,只有一个子目录,名为 ru(我猜是俄语)。我正在研究默认英语的系统和浏览器。
我正在使用出现此问题时最新的 TG2 发行版 v. 2.1.3 和 tg.devtools 2.1.x
I am new to TurboGears and have just installed TG2 development in a virtual environment. I'm following along in the quickstart guide, and have successfully built a helloworld via
paster quickstart
I started the server and navigated a web-browser to localhost:8080
Wouldn't you know it, I immediately get an error, and not the welcome message the documentation suggests I should be seeing.
The error reads:
AttributeError: 'AcceptLanguage' object has no attribute 'best_matches'
Here's the trace:
URL: http://localhost:8080/
File 'C:\\VirtualEnv_1\\lib\\site-packages\\weberror-0.10.3-py2.7.egg\\weberror\\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\beaker-1.6-py2.7.egg\\beaker\\middleware.py', line 73 in __call__
return self.app(environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\beaker-1.6-py2.7.egg\\beaker\\middleware.py', line 155 in __call__
return self.wrap_app(environ, session_start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\routes-1.12.3-py2.7.egg\\routes\\middleware.py', line 131 in __call__
response = self.app(environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\wsgiapp.py', line 107 in __call__
response = self.dispatch(controller, environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\wsgiapp.py', line 312 in dispatch
return controller(environ, start_response)
File 'C:\\VirtualEnv_1\\Scripts\\HelloWorld\\helloworld\\lib\\base.py', line 27 in __call__
return TGController.__call__(self, environ, start_response)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 211 in __call__
response = self._dispatch_call()
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 162 in _dispatch_call
response = self._inspect_call(func)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 105 in _inspect_call
result = self._perform_call(func, args)
File 'C:\\VirtualEnv_1\\lib\\site-packages\\turbogears2-2.1.3-py2.7.egg\\tg\\controllers\\dispatcher.py', line 230 in _perform_call
setup_i18n()
File 'C:\\VirtualEnv_1\\lib\\site-packages\\turbogears2-2.1.3-py2.7.egg\\tg\\i18n.py', line 61 in setup_i18n
pylons.request.accept_language.best_matches()))
AttributeError: 'AcceptLanguage' object has no attribute 'best_matches'
Did I mess something up when I installed it, or is this a problem with TurboGears?
Edit: I created a second project I named GoodnightMoon, this time without the Mako template option (which is the only difference between setups) and I get the same error:
'AcceptLanguage' object has no attribute 'best_matches'
Unfortunately this question is the only one I can find with a web search related exactly to this error.
Are there any other clues I can use and provide to stackoverflow to assist in answering this question?
Following Michael Pederson's advice below, I researched the i18n. I have an i18n directory with only one sub-directory, named ru (Russian, I assume). I'm working on English-defaulted systems and browsers.
I'm using whatever the most current TG2 distro is at the time of this question, v. 2.1.3, and tg.devtools 2.1.x
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对 WebOb 错误依赖的问题。安装的 IIRC 1.2b2 缺少 AcceptLanguage 类上的 best_matches 方法。克服该问题的最简单方法是将 WebOb-1.2b2 替换为稳定的 WebOb-1.1.1。
这个解决方案对我来说效果很好。
PS:如果您使用 virtual-env - 只需将 lib/python2.7/site-packages/webob 中的文件替换为官方网站 http://pypi.python.org/pypi/WebOb/1.1.1
The problem in wrong dependency to WebOb. IIRC 1.2b2 is installed which lack best_matches method on AcceptLanguage class. The easiest way to overcome that trouble is to replace WebOb-1.2b2 with stable WebOb-1.1.1.
This solution works fine for me.
PS: if you use virtual-env - just replace files inside lib/python2.7/site-packages/webob with ones from official site http://pypi.python.org/pypi/WebOb/1.1.1