Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatch() takes exactly 3 arguments (2 given) #66

Open
kevthehermit opened this issue Jun 6, 2016 · 4 comments
Open

dispatch() takes exactly 3 arguments (2 given) #66

kevthehermit opened this issue Jun 6, 2016 · 4 comments

Comments

@kevthehermit
Copy link

Currently all the docs use

urlpatterns = patterns('',
    url(r'^(?P<path>.*)$', TestProxyView.as_view()),
)

Tested working ok with this style of urlpatterns BUT as of Django 1.10 (currently 1.9.7) this will be removed.

RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
  url(r'^(?P<path>.*)$', TestProxyView.as_view()),

Trying the new stlye of url from django docs

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', TestProxyView.as_view()),
    url(r'createsession/', TestProxyView.as_view(), name='session'),

Gives the following error

Environment:


Request Method: GET
Request URL: http://192.168.1.105:8000/createsession/

Django Version: 1.9.7
Python Version: 2.7.11
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'revproxy',
 'Portal']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

Exception Type: TypeError at /createsession/
Exception Value: dispatch() takes exactly 3 arguments (2 given)
@dfeinzeig
Copy link

Also busted in 1.8.

@dimrozakis
Copy link
Contributor

@kevthehermit I think the error dispatch() takes exactly 3 arguments (2 given) is raised because there is no path matched in the url regex, and therefore path isn't sent to the view, which expects it as a required argument (to know to which path it should proxy to). You should have a part like this in the url regex: (?P<path>.*)

@seocam seocam added the bug label Mar 20, 2017
mccalluc added a commit to refinery-platform/django_docker_engine that referenced this issue Mar 29, 2018
mccalluc added a commit to refinery-platform/django_docker_engine that referenced this issue Mar 29, 2018
* Checkpoint: 4 failures. swap in new proxy and improve failure message

* Fix two test failures. Change suggested by jazzband/django-revproxy#66 (comment)

* Not sure why the nginx 404 seemed to change?

* isort

* Move paramiko inside the one method that would use it.
@seocam seocam removed the bug label Jun 6, 2020
@seocam
Copy link
Contributor

seocam commented Jun 6, 2020

@kevthehermit did you manage to get it working. @mccalluc I see you referenced this issue as well. Do you see a problem here? Perhaps we should improve docs or error msgs somehow?

@mccalluc
Copy link
Contributor

mccalluc commented Jun 6, 2020

I don't remember the details, but it looks like my first try had used a path kwarg, when url was what I needed. I was fairly new to django at the time, so perhaps with more familiarity it would have been less confusing for me? Your call.

@seocam seocam added this to the 1.0 milestone Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants