Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyramid config loading error

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.

like image 566
viraptor Avatar asked Feb 12 '26 20:02

viraptor


1 Answers

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.

like image 111
Martijn Pieters Avatar answered Feb 14 '26 12:02

Martijn Pieters



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!