Permalink
Comparing changes
Open a pull request
- 9 commits
- 4 files changed
- 0 commit comments
- 3 contributors
Unified
Split
Showing
with
27 additions
and 3 deletions.
- +5 −0 CHANGES.txt
- +2 −0 CONTRIBUTORS.txt
- +6 −1 pyramid/config/predicates.py
- +14 −2 pyramid/tests/test_config/test_predicates.py
| @@ -10,6 +10,11 @@ unreleased | ||
| ``[app:main]`` and ``[server:main]``. | ||
| See https://github.com/Pylons/pyramid/pull/2292 | ||
| - Allow a leading ``=`` on the key of the request param predicate. | ||
| For example, '=abc=1' is equivalent down to | ||
| ``request.params['=abc'] == '1'``. | ||
| See https://github.com/Pylons/pyramid/pull/1370 | ||
| 1.6 (2015-04-14) | ||
| ================ | ||
| @@ -247,6 +247,8 @@ Contributors | ||
| - Donald Stufft, 2015/03/15 | ||
| - Timur Izhbulatov, 2015/04/14 | ||
| - Karen Dalton, 2015/06/01 | ||
| - Igor Stroh, 2015/06/10 | ||
| @@ -70,7 +70,12 @@ def __init__(self, val, config): | ||
| for p in val: | ||
| k = p | ||
| v = None | ||
| if '=' in p: | ||
| if p.startswith('='): | ||
| if '=' in p[1:]: | ||
| k, v = p[1:].split('=', 1) | ||
| k = '=' + k | ||
| k, v = k.strip(), v.strip() | ||
| elif '=' in p: | ||
| k, v = p.split('=', 1) | ||
| k, v = k.strip(), v.strip() | ||
| reqs.append((k, v)) | ||
| @@ -120,9 +120,9 @@ def test___call___true_withval(self): | ||
| self.assertTrue(result) | ||
| def test___call___true_multi(self): | ||
| inst = self._makeOne(('abc', 'def =2 ')) | ||
| inst = self._makeOne(('abc', '=def =2= ')) | ||
| request = Dummy() | ||
| request.params = {'abc':'1', 'def': '2'} | ||
| request.params = {'abc':'1', '=def': '2='} | ||
| result = inst(None, request) | ||
| self.assertTrue(result) | ||
| @@ -144,6 +144,10 @@ def test_text_exists(self): | ||
| inst = self._makeOne('abc') | ||
| self.assertEqual(inst.text(), 'request_param abc') | ||
| def test_text_exists_equal_sign(self): | ||
| inst = self._makeOne('=abc') | ||
| self.assertEqual(inst.text(), 'request_param =abc') | ||
| def test_text_withval(self): | ||
| inst = self._makeOne('abc= 1') | ||
| self.assertEqual(inst.text(), 'request_param abc=1') | ||
| @@ -152,10 +156,18 @@ def test_text_multi(self): | ||
| inst = self._makeOne(('abc= 1', 'def')) | ||
| self.assertEqual(inst.text(), 'request_param abc=1,def') | ||
| def test_text_multi_equal_sign(self): | ||
| inst = self._makeOne(('abc= 1', '=def= 2')) | ||
| self.assertEqual(inst.text(), 'request_param =def=2,abc=1') | ||
| def test_phash_exists(self): | ||
| inst = self._makeOne('abc') | ||
| self.assertEqual(inst.phash(), 'request_param abc') | ||
| def test_phash_exists_equal_sign(self): | ||
| inst = self._makeOne('=abc') | ||
| self.assertEqual(inst.phash(), 'request_param =abc') | ||
| def test_phash_withval(self): | ||
| inst = self._makeOne('abc= 1') | ||
| self.assertEqual(inst.phash(), "request_param abc=1") | ||