TypeError: view() takes exactly 2 arguments (3 given) #503

Closed
fafhrd91 opened this Issue Mar 20, 2012 · 1 comment

2 participants

@fafhrd91

pyramid 1.3b3


127.0.0.1 - - [2012-03-19 19:23:53] "GET /_jca/connection/info HTTP/1.1" 500 161 0.003054
Traceback (most recent call last):
  File "/home/fafhrd/dev/eggs/gevent-1.0b1-py2.7-linux-i686.egg/gevent/pywsgi.py", line 449, in handle_one_response
    self.run_application()
  File "/home/fafhrd/dev/eggs/gevent-1.0b1-py2.7-linux-i686.egg/gevent/pywsgi.py", line 435, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/home/fafhrd/dev/eggs/pyramid-1.3b3-py2.7.egg/pyramid/router.py", line 187, in __call__
    response = self.handle_request(request)
  File "/home/fafhrd/dev/eggs/pyramid-1.3b3-py2.7.egg/pyramid/tweens.py", line 20, in excview_tween
    response = handler(request)
  File "/home/fafhrd/dev/eggs/pyramid_tm-0.3-py2.7.egg/pyramid_tm/__init__.py", line 61, in tm_tween
    response = handler(request)
  File "/home/fafhrd/dev/eggs/pyramid-1.3b3-py2.7.egg/pyramid/router.py", line 164, in handle_request
    response = view_callable(context, request)
  File "/home/fafhrd/dev/eggs/pyramid-1.3b3-py2.7.egg/pyramid/config/views.py", line 370, in viewresult_to_response
    result = view(context, request)
  File "/home/fafhrd/dev/eggs/pyramid-1.3b3-py2.7.egg/pyramid/config/views.py", line 152, in text_wrapper
    return view(context, request)
TypeError: view() takes exactly 2 arguments (3 given

Example code:

class Foo(object):

  def view(self, request):
       ...

obj = Foo()
config.add_view(obj.view, route_name='...')

this code worked in pyramid-1.3b2, regression seems added in #461

@mcdonc mcdonc added a commit that closed this issue Mar 20, 2012
@mcdonc mcdonc - The fix for issue #461 (which made
  it possible for instance methods to be used as view callables) introduced a
  backwards incompatibility when methods that declared only a request
  argument were used.  See #503

Fixes #503
6c15971
@mcdonc mcdonc closed this in 6c15971 Mar 20, 2012
@mcdonc
Pylons Project member

Thanks! It's now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment