Skip to content

Commit

Permalink
[#4796] Update friendly form plugin
Browse files Browse the repository at this point in the history
* Change urllib imports to six ones
* Replace usage of paster methods
  • Loading branch information
amercader committed Jul 19, 2019
1 parent b23fe3e commit 0e1b68a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions ckan/lib/repoze_plugins/friendly_form.py
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
'''
This is a modified version of repoze.who-friendlyform, written by
Gustavo Narea <me@gustavonarea.net>
'''


##############################################################################
#
# Copyright (c) 2009-2010, Gustavo Narea <me@gustavonarea.net> and contributors.
Expand All @@ -15,24 +21,21 @@

"""Collection of :mod:`repoze.who` friendly forms"""

from urlparse import urlparse, urlunparse
from urllib import urlencode
try:
from urlparse import parse_qs
except ImportError:#pragma: no cover
from cgi import parse_qs
from six.moves.urllib.parse import urlparse, urlunparse, urlencode, parse_qs

from webob import Request
# TODO: Stop using Paste; we already started using WebOb
from webob import Request, UnicodeMultiDict
from webob.exc import HTTPFound, HTTPUnauthorized
from paste.request import construct_url, parse_dict_querystring, parse_formvars
from zope.interface import implements

from repoze.who.interfaces import IChallenger, IIdentifier

__all__ = ['FriendlyFormPlugin']


def construct_url(environ):
return Request(environ).url


class FriendlyFormPlugin(object):
"""
:class:`RedirectingFormPlugin
Expand Down Expand Up @@ -172,7 +175,9 @@ def identify(self, environ):

elif path_info == self.logout_handler_path:
## We are on the URL where repoze.who logs the user out. ##
form = parse_formvars(environ)
r = Request(environ)
params = dict(list(r.GET.items()) + list(r.POST.items()))
form = UnicodeMultiDict(params)
form.update(query)
referer = environ.get('HTTP_REFERER', script_name)
came_from = form.get('came_from', referer)
Expand Down Expand Up @@ -273,7 +278,7 @@ def _get_logins(self, environ, force_typecast=False):
Otherwise, it will be ``None`` or an string.
"""
variables = parse_dict_querystring(environ)
variables = Request(environ).queryvars
failed_logins = variables.get(self.login_counter_name)
if force_typecast:
try:
Expand Down

0 comments on commit 0e1b68a

Please sign in to comment.