Skip to content

Commit

Permalink
[#4801] Handle webob py2/3 differences in friendly form
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Dec 6, 2019
1 parent 126f862 commit 92326d1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ckan/lib/repoze_plugins/friendly_form.py
Expand Up @@ -28,7 +28,12 @@

from six.moves.urllib.parse import urlparse, urlunparse, urlencode, parse_qs

from webob import Request, UnicodeMultiDict
from webob import Request
try:
from webob import UnicodeMultiDict as multidict
except ImportError:
from webob import multidict

from webob.exc import HTTPFound, HTTPUnauthorized
from zope.interface import implementer

Expand Down Expand Up @@ -182,7 +187,7 @@ def identify(self, environ):
# We are on the URL where repoze.who logs the user out. #
r = Request(environ)
params = dict(list(r.GET.items()) + list(r.POST.items()))
form = UnicodeMultiDict(params)
form = multidict(params)
form.update(query)
referer = environ.get(u'HTTP_REFERER', script_name)
came_from = form.get(u'came_from', referer)
Expand Down Expand Up @@ -285,7 +290,13 @@ def _get_logins(self, environ, force_typecast=False):
Otherwise, it will be ``None`` or an string.
'''
variables = Request(environ).queryvars
try:
# Webob 1.8.5 (py3)
variables = Request(environ).params
except AttributeError:
# Webob 1.0.8 (py2)
variables = Request(environ).queryvars

failed_logins = variables.get(self.login_counter_name)
if force_typecast:
try:
Expand Down

0 comments on commit 92326d1

Please sign in to comment.