summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-11-27 04:23:22 -0500
committerChris McDonough <chrism@plope.com>2013-11-27 04:23:22 -0500
commit06aee8b0c35d5fdcd305ff6c7107d936bcdb7d32 (patch)
treec46a7a9396560c1b4e3eb8fd6ace33b1be444aae
parentf82f91a74b51b79c3c81ac38cf91f6e544991218 (diff)
downloadpyramid-06aee8b0c35d5fdcd305ff6c7107d936bcdb7d32.tar.gz
pyramid-06aee8b0c35d5fdcd305ff6c7107d936bcdb7d32.tar.bz2
pyramid-06aee8b0c35d5fdcd305ff6c7107d936bcdb7d32.zip
change the behavior of parse_url_overrides and resource_url to not quote a _query/query argument supplied as a string and document in changelog
-rw-r--r--CHANGES.txt17
-rw-r--r--pyramid/tests/test_url.py1
-rw-r--r--pyramid/url.py57
3 files changed, 40 insertions, 35 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index d6f5ea792..40efecce1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -48,17 +48,24 @@ Features
timeouts, and conformance with the ``ISession`` API.
See https://github.com/Pylons/pyramid/pull/1142
-- Allow ``pyramid.request.Request.route_url`` and
- ``pyramid.request.Request.resource_url`` to accept strings for their
- query string to enable alternative encodings. Also the anchor argument
- will now be escaped to ensure minimal conformance.
- See https://github.com/Pylons/pyramid/pull/1183
+- The anchor argument to ``pyramid.request.Request.route_url`` and
+ ``pyramid.request.Request.resource_url`` and their derivatives will now be
+ escaped to ensure minimal conformance. See
+ https://github.com/Pylons/pyramid/pull/1183
- Allow sending of ``_query`` and ``_anchor`` options to
``pyramid.request.Request.static_url`` when an external URL is being
generated.
See https://github.com/Pylons/pyramid/pull/1183
+- You can now send a string as the ``_query`` argument to
+ ``pyramid.request.Request.route_url`` and
+ ``pyramid.request.Request.resource_url`` and their derivatives. When a
+ string is sent instead of a list or dictionary. it is not URL-encoded or
+ quoted; the caller must perform this job before passing it in. This is
+ useful if you want to be able to use a different query string format than
+ ``x-www-form-urlencoded``. See https://github.com/Pylons/pyramid/pull/1183
+
Bug Fixes
---------
diff --git a/pyramid/tests/test_url.py b/pyramid/tests/test_url.py
index 22ccd1d0e..0a788ba97 100644
--- a/pyramid/tests/test_url.py
+++ b/pyramid/tests/test_url.py
@@ -6,7 +6,6 @@ from pyramid import testing
from pyramid.compat import (
text_,
- native_,
WIN,
)
diff --git a/pyramid/url.py b/pyramid/url.py
index 14f4add35..06e7e6a81 100644
--- a/pyramid/url.py
+++ b/pyramid/url.py
@@ -48,7 +48,7 @@ def parse_url_overrides(kw):
if '_query' in kw:
query = kw.pop('_query')
if isinstance(query, string_types):
- qs = '?' + url_quote(query, QUERY_SAFE)
+ qs = '?' + query
elif query:
qs = '?' + urlencode(query, doseq=True)
@@ -167,22 +167,21 @@ class URLMethodsMixin(object):
``*remainder`` replacement value, it is tacked on to the URL
after being URL-quoted-except-for-embedded-slashes.
- If no ``_query`` keyword argument is provided, the request
- query string will be returned in the URL. If it is present, it
- will be used to compose a query string that will be tacked on
- to the end of the URL, replacing any request query string.
- The value of ``_query`` may be a sequence of two-tuples *or*
- a data structure with an ``.items()`` method that returns a
- sequence of two-tuples (presumably a dictionary). This data
- structure will be turned into a query string per the
- documentation of :func:`pyramid.url.urlencode` function.
- Alternative encodings may be used by passing a string for ``_query``
- in which case it will be quoted as per :rfc:`3986#section-3.4` but
- no other assumptions will be made about the data format. For example,
- spaces will be escaped as ``%20`` instead of ``+``.
- After the query data is turned into a query string, a leading
- ``?`` is prepended, and the resulting string is appended to
- the generated URL.
+ If no ``_query`` keyword argument is provided, the request query string
+ will be returned in the URL. If it is present, it will be used to
+ compose a query string that will be tacked on to the end of the URL,
+ replacing any request query string. The value of ``_query`` may be a
+ sequence of two-tuples *or* a data structure with an ``.items()``
+ method that returns a sequence of two-tuples (presumably a dictionary).
+ This data structure will be turned into a query string per the
+ documentation of :func:`pyramid.url.urlencode` function. This will
+ produce a query string in the ``x-www-form-urlencoded`` format. A
+ non-``x-www-form-urlencoded`` encoding may be used by passing a
+ *string* value as ``_query`` in which case it will be used without
+ quoting or encoding; it is left up to the caller to do both and if he
+ does not, an invalid URL may be generated. After the query data is
+ turned into a query string, a leading ``?`` is prepended, and the
+ resulting string is appended to the generated URL.
.. note::
@@ -361,17 +360,17 @@ class URLMethodsMixin(object):
``elements`` are used, the generated URL will *not*
end in trailing a slash.
- If a keyword argument ``query`` is present, it will be used to
- compose a query string that will be tacked on to the end of the URL.
- The value of ``query`` may be a sequence of two-tuples *or* a data
- structure with an ``.items()`` method that returns a sequence of
- two-tuples (presumably a dictionary). This data structure will be
- turned into a query string per the documentation of
- :func:``pyramid.url.urlencode`` function.
- Alternative encodings may be used by passing a string for ``query``
- in which case it will be quoted as per :rfc:`3986#section-3.4` but
- no other assumptions will be made about the data format. For example,
- spaces will be escaped as ``%20`` instead of ``+``.
+ If a keyword argument ``query`` is present, it will be used to compose
+ a query string that will be tacked on to the end of the URL. The value
+ of ``query`` may be a sequence of two-tuples *or* a data structure with
+ an ``.items()`` method that returns a sequence of two-tuples
+ (presumably a dictionary). This data structure will be turned into a
+ query string per the documentation of :func:``pyramid.url.urlencode``
+ function. This will produce a query string in the
+ ``x-www-form-urlencoded`` encoding. A non-``x-www-form-urlencoded``
+ query string may be used by passing a *string* value as ``query`` in
+ which case it will be used without quoting or encoding; it is up to the
+ caller to do both and if he does not an invalid URL may be generated.
After the query data is turned into a query string, a leading ``?`` is
prepended, and the resulting string is appended to the generated URL.
@@ -620,7 +619,7 @@ class URLMethodsMixin(object):
if 'query' in kw:
query = kw['query']
if isinstance(query, string_types):
- qs = '?' + url_quote(query, QUERY_SAFE)
+ qs = '?' + query
elif query:
qs = '?' + urlencode(query, doseq=True)