From bbc4f46ccf6b3e9c2235f0fd60622a0deff6b30e Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 27 Sep 2011 00:12:26 -0400 Subject: backport typo fix --- docs/narr/hooks.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 3ab82ecf7..7db1eca73 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -863,8 +863,8 @@ Pyramid request handling function or another tween. ``registry`` will be the Pyramid :term:`application registry` represented by this Configurator. A tween factory must return a tween when it is called. -A tween is a callable which accepts a :term:`request` object and returns a -two-tuple a :term:`response` object. +A tween is a callable which accepts a :term:`request` object and returns +a :term:`response` object. Here's an example of a tween factory: -- cgit v1.2.3 From dd5a91eb937369d06f3fc438c817e046fc81f891 Mon Sep 17 00:00:00 2001 From: Wichert Akkerman Date: Wed, 28 Sep 2011 10:37:40 +0200 Subject: Accept unicode token instances with ascii content This is required when reissueing cookies which include a token: WebOb returns the tokens from a cookie as unicode instances, so remember() must be able to deal with them when refreshing. --- pyramid/authentication.py | 2 +- pyramid/tests/test_authentication.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pyramid/authentication.py b/pyramid/authentication.py index e38c984b3..ed422b044 100644 --- a/pyramid/authentication.py +++ b/pyramid/authentication.py @@ -729,7 +729,7 @@ class AuthTktCookieHelper(object): for token in tokens: if isinstance(token, text_type): try: - token.encode('ascii') + token = token.encode('ascii') except UnicodeEncodeError: raise ValueError("Invalid token %r" % (token,)) if not (isinstance(token, str) and VALID_TOKEN.match(token)): diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index b612c5789..6b8393fc2 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -616,6 +616,7 @@ class TestAuthTktCookieHelper(unittest.TestCase): now = time.time() helper.auth_tkt.timestamp = now helper.now = now + 1 + helper.auth_tkt.tokens = (u'a', ) request = self._makeRequest('bogus') result = helper.identify(request) self.assertTrue(result) @@ -907,6 +908,12 @@ class TestAuthTktCookieHelper(unittest.TestCase): self.assertEqual(result[2][0], 'Set-Cookie') self.assertTrue("'tokens': ('foo', 'bar')" in result[2][1]) + def test_remember_unicode_but_ascii_token(self): + helper = self._makeOne('secret') + request = self._makeRequest() + la = text_(b'foo', 'utf-8') + helper.remember(request, 'other', tokens=(la,)) + def test_remember_nonascii_token(self): helper = self._makeOne('secret') request = self._makeRequest() -- cgit v1.2.3 From 9f2d38c1cf8b88658c3600afab195cb3686300b8 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 28 Sep 2011 04:55:24 -0400 Subject: fix for py32, avoid setup.py conflict --- pyramid/authentication.py | 3 ++- pyramid/tests/test_authentication.py | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyramid/authentication.py b/pyramid/authentication.py index ed422b044..245a9692f 100644 --- a/pyramid/authentication.py +++ b/pyramid/authentication.py @@ -14,6 +14,7 @@ from pyramid.compat import binary_type from pyramid.compat import url_unquote from pyramid.compat import url_quote from pyramid.compat import bytes_ +from pyramid.compat import ascii_native_ from pyramid.interfaces import IAuthenticationPolicy from pyramid.interfaces import IDebugLogger @@ -729,7 +730,7 @@ class AuthTktCookieHelper(object): for token in tokens: if isinstance(token, text_type): try: - token = token.encode('ascii') + token = ascii_native_(token) except UnicodeEncodeError: raise ValueError("Invalid token %r" % (token,)) if not (isinstance(token, str) and VALID_TOKEN.match(token)): diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py index 6b8393fc2..6bf14e76c 100644 --- a/pyramid/tests/test_authentication.py +++ b/pyramid/tests/test_authentication.py @@ -616,7 +616,7 @@ class TestAuthTktCookieHelper(unittest.TestCase): now = time.time() helper.auth_tkt.timestamp = now helper.now = now + 1 - helper.auth_tkt.tokens = (u'a', ) + helper.auth_tkt.tokens = (text_('a'), ) request = self._makeRequest('bogus') result = helper.identify(request) self.assertTrue(result) diff --git a/setup.py b/setup.py index aa8045a9a..3334a01d6 100644 --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ if not PY3: ]) setup(name='pyramid', - version='1.2', + version='1.3dev', description=('The Pyramid web application development framework, a ' 'Pylons project'), long_description=README + '\n\n' + CHANGES, -- cgit v1.2.3