金字塔配置加载错误
我在 Pyramid 中创建应用程序时遇到问题。当我尝试通过粘贴服务时,我得到:
File "/home/viraptor/blah/blah/__init__.py", line 23, in main
return config.make_wsgi_app()
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 916, in make_wsgi_app
self.commit()
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 491, in commit
self._ctx.execute_actions()
File "/home/viraptor/pyramid/lib/python2.6/site-packages/zope/configuration/config.py", line 626, in execute_actions
callable(*args, **kw)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 1291, in register
derived_view = deriver(view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2681, in __call__
self.mapped_view(view))))))))
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2624, in inner
wrapped_view = wrapped(self, view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2693, in mapped_view
mapped_view = mapper(**self.kw)(view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2860, in __call__
view = self.map_nonclass(view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2876, in map_nonclass
ronly = requestonly(view, self.attr)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2966, in requestonly
if len(args) - len(defaults) == 1:
zope.configuration.config.ConfigurationExecutionError: <type 'exceptions.TypeError'>: object of type 'NoneType' has no len()
in:
('/home/viraptor/blah/blah/__init__.py', 22, 'main', "config.add_route('customer', '/customer/{customer_id}', view='blah.views.customer.view', view_renderer='customer_view.mak', view_permission='view', traverse='/customer/{customer_id}')")
这可能是什么原因?我最近甚至没有更改该配置,仅更改了应用程序的其余部分。
I've got an issue with creating an app in Pyramid. When I try to serve through paster, I get:
File "/home/viraptor/blah/blah/__init__.py", line 23, in main
return config.make_wsgi_app()
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 916, in make_wsgi_app
self.commit()
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 491, in commit
self._ctx.execute_actions()
File "/home/viraptor/pyramid/lib/python2.6/site-packages/zope/configuration/config.py", line 626, in execute_actions
callable(*args, **kw)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 1291, in register
derived_view = deriver(view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2681, in __call__
self.mapped_view(view))))))))
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2624, in inner
wrapped_view = wrapped(self, view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2693, in mapped_view
mapped_view = mapper(**self.kw)(view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2860, in __call__
view = self.map_nonclass(view)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2876, in map_nonclass
ronly = requestonly(view, self.attr)
File "/home/viraptor/pyramid/lib/python2.6/site-packages/pyramid/config.py", line 2966, in requestonly
if len(args) - len(defaults) == 1:
zope.configuration.config.ConfigurationExecutionError: <type 'exceptions.TypeError'>: object of type 'NoneType' has no len()
in:
('/home/viraptor/blah/blah/__init__.py', 22, 'main', "config.add_route('customer', '/customer/{customer_id}', view='blah.views.customer.view', view_renderer='customer_view.mak', view_permission='view', traverse='/customer/{customer_id}')")
What can be the reason for this? I haven't even changed that configuration lately, only the rest of the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑你遇到了金字塔新版本中修复的错误;您的回溯表明
args
或defaults
为None
,但除非args
不存在,否则无法到达该代码分支None
,保留defaults
为None
的可能性。我发现以下对 Pyramids 的提交添加了对defaults
为 None 的特定测试:https://github.com/Pylons/pyramid/commit/f168197609169fb01b65adeb3eb59d069000fe2c
我说你有一个没有任何默认值并且只有一个请求参数的方法(
method(self, request)< /code>,解决方法是添加一个带有默认值的关键字参数 (
method(self, request, dummy=None)
:还没有机会使用 Pyramid,因此我的分析纯粹基于 Pyramid 代码库。
I suspect you hit a bug fixed in newer revisions of Pyramid; your traceback indicates that either
args
ordefaults
isNone
, but that code branch cannot be reached unlessargs
is notNone
, leaving the possibility thatdefaults
isNone
instead. I found the following commit to Pyramids that adds a specific test fordefaults
being None:https://github.com/Pylons/pyramid/commit/f168197609169fb01b65adeb3eb59d069000fe2c
I say you have a method without any defaults and only a request parameter (
method(self, request)
, the work-around would be to add a keyword argument with a default (method(self, request, dummy=None)
.Disclaimer: haven't yet had a chance to work with Pyramid, so my analysis is based purely on the Pyramid codebase.
config.add_route
仅接受 1 个位置参数,第二个参数应使用带有pattern
的关键字。其次,我认为
route
和traverse
不可能有相同的模式。使用traverse
关键字,您可以定义root
应该开始的位置。它在Configurator< 中进行了解释/code> API 文档
。
不过,引发的错误异常可能会提供更多信息。
config.add_route
accepts only 1 positional argument, your second argument should be use keyworded withpattern
.Secondly, I don't think is possible to have the same pattern for
route
and thetraverse
. With thetraverse
keyword you are definining where theroot
should start. It's explained in theConfigurator
API documentation.The error exception raised could more informative though.