Revision 68122bae snf-astakos-app/astakos/oa2/backends/base.py

b/snf-astakos-app/astakos/oa2/backends/base.py
44 44
logger = logging.getLogger(__name__)
45 45

  
46 46

  
47
def urlencode(params):
48
    if hasattr(params, 'urlencode') and callable(getattr(params, 'urlencode')):
49
        return params.urlencode()
50
    return urllib.urlencode(params)
51

  
52

  
47 53
def handles_oa2_requests(func):
48 54
    def wrapper(self, *args, **kwargs):
49 55
        if not self._errors_to_http:
......
341 347
        return bool(self.get_client_by_id(client_id))
342 348

  
343 349
    def build_site_url(self, prefix='', **params):
344
        params = urllib.urlencode(params)
350
        params = urlencode(params)
345 351
        return "%s%s%s%s" % (self.base_url, self.endpoints_prefix, prefix,
346 352
                             params)
347 353

  
......
352 358
    def build_client_redirect_uri(self, client, uri, **params):
353 359
        if not client.redirect_uri_is_valid(uri):
354 360
            raise OA2Error("Invalid redirect uri")
355
        params = urllib.urlencode(params)
361
        params = urlencode(params)
356 362
        uri = self._get_uri_base(uri)
357 363
        return "%s?%s" % (uri, params)
358 364

  
......
396 402

  
397 403
    def redirect_to_login_response(self, request, params):
398 404
        parts = list(urlparse.urlsplit(request.path))
399
        parts[3] = urllib.urlencode(params)
405
        parts[3] = urlencode(params)
400 406
        query = {'next': urlparse.urlunsplit(parts)}
401 407
        return Response(302,
402 408
                        headers={'Location': '%s?%s' %
403 409
                                 (self.get_login_uri(),
404
                                  urllib.urlencode(query))})
410
                                  urlencode(query))})
405 411

  
406 412
    def redirect_to_uri(self, redirect_uri, code, state=None):
407 413
        parts = list(urlparse.urlsplit(redirect_uri))
......
409 415
        params['code'] = code
410 416
        if state is not None:
411 417
            params['state'] = state
412
        parts[3] = urllib.urlencode(params)
418
        parts[3] = urlencode(params)
413 419
        return Response(302,
414 420
                        headers={'Location': '%s' %
415 421
                                 urlparse.urlunsplit(parts)})

Also available in: Unified diff