金字塔配置加载错误

发布于 2024-11-02 19:52:24 字数 1979 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天冷不及心凉 2024-11-09 19:52:24

我怀疑你遇到了金字塔新版本中修复的错误;您的回溯表明 argsdefaultsNone,但除非 args 不存在,否则无法到达该代码分支None,保留 defaultsNone 的可能性。我发现以下对 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 or defaults is None, but that code branch cannot be reached unless args is not None, leaving the possibility that defaults is None instead. I found the following commit to Pyramids that adds a specific test for defaults 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.

信愁 2024-11-09 19:52:24

config.add_route 仅接受 1 个位置参数,第二个参数应使用带有 pattern 的关键字。

其次,我认为 routetraverse 不可能有相同的模式。使用traverse关键字,您可以定义root应该开始的位置。它在 Configurator< 中进行了解释/code> API 文档

不过,引发的错误异常可能会提供更多信息。

config.add_route accepts only 1 positional argument, your second argument should be use keyworded with pattern.

Secondly, I don't think is possible to have the same pattern for route and the traverse. With the traverse keyword you are definining where the root should start. It's explained in the Configurator API documentation.

The error exception raised could more informative though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文