From 804232f6ea90a5e537ccd46d87b66a976f736c0c Mon Sep 17 00:00:00 2001
From: drnextgis <rykovd@gmail.com>
Date: Thu, 15 Jun 2017 18:48:07 +0200
Subject: [PATCH] quote_via urlencode argument

---
 pyramid/encode.py |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/pyramid/encode.py b/pyramid/encode.py
index 0be0107..62f9693 100644
--- a/pyramid/encode.py
+++ b/pyramid/encode.py
@@ -14,7 +14,16 @@
         val = str(val).encode('utf-8')
     return _url_quote(val, safe=safe)
 
-def urlencode(query, doseq=True):
+# bw compat api (dnr)
+def quote_plus(val, safe=''):
+    cls = val.__class__
+    if cls is text_type:
+        val = val.encode('utf-8')
+    elif cls is not binary_type:
+        val = str(val).encode('utf-8')
+    return _quote_plus(val, safe=safe)
+
+def urlencode(query, doseq=True, quote_via=quote_plus):
     """
     An alternate implementation of Python's stdlib `urllib.urlencode
     function <http://docs.python.org/library/urllib.html>`_ which
@@ -52,28 +61,19 @@
     prefix = ''
 
     for (k, v) in query:
-        k = quote_plus(k)
+        k = quote_via(k)
 
         if is_nonstr_iter(v):
             for x in v:
-                x = quote_plus(x)
+                x = quote_via(x)
                 result += '%s%s=%s' % (prefix, k, x)
                 prefix = '&'
         elif v is None:
             result += '%s%s=' % (prefix, k)
         else:
-            v = quote_plus(v)
+            v = quote_via(v)
             result += '%s%s=%s' % (prefix, k, v)
 
         prefix = '&'
 
     return result
-
-# bw compat api (dnr)
-def quote_plus(val, safe=''):
-    cls = val.__class__
-    if cls is text_type:
-        val = val.encode('utf-8')
-    elif cls is not binary_type:
-        val = str(val).encode('utf-8')
-    return _quote_plus(val, safe=safe)

--
Gitblit v1.9.3