From 07299bff4bf643456502fa39b9418882316815d7 Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Fri, 14 Jan 2011 17:39:37 -0500 Subject: Added tab-width: 2 to literalinclude to see if it formats better :) --- docs/tutorials/wiki/definingviews.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/tutorials/wiki/definingviews.rst b/docs/tutorials/wiki/definingviews.rst index 90768f320..fe0072c2a 100644 --- a/docs/tutorials/wiki/definingviews.rst +++ b/docs/tutorials/wiki/definingviews.rst @@ -231,6 +231,7 @@ the below: .. literalinclude:: src/views/tutorial/templates/view.pt :language: xml + :tab-width: 2 .. note:: The names available for our use in a template are always those that are present in the dictionary returned by the view callable. But our -- cgit v1.2.3 From 49315b643983789e668626474c22beec3117457e Mon Sep 17 00:00:00 2001 From: Ben Bangert Date: Sat, 15 Jan 2011 11:37:10 -0800 Subject: - URL Dispatch properly handles a '.*' or '*' appearing in a regex match when used inside brackets. Resolve Issue #90. --- CHANGES.txt | 6 ++++++ pyramid/tests/test_urldispatch.py | 11 +++++++++++ pyramid/urldispatch.py | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index d8853593b..fc1a53dd7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,12 @@ Next release ============ +Bug Fixes +--------- + +- URL Dispatch properly handles a '.*' or '*' appearing in a regex match + when used inside brackets. Resolve Issue #90. + Features -------- diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py index 12c5cf220..a452fdb97 100644 --- a/pyramid/tests/test_urldispatch.py +++ b/pyramid/tests/test_urldispatch.py @@ -239,6 +239,17 @@ class TestCompileRoute(unittest.TestCase): self.assertEqual(matcher('foo/baz/biz/buz/bar'), None) self.assertEqual(generator( {'baz':1, 'buz':2, 'traverse':u'/a/b'}), '/foo/1/biz/2/bar/a/b') + + def test_with_bracket_star(self): + matcher, generator = self._callFUT('/foo/{baz}/biz/{buz}/bar{remainder:.*}') + self.assertEqual(matcher('/foo/baz/biz/buz/bar'), + {'baz':'baz', 'buz':'buz', 'remainder':''}) + self.assertEqual(matcher('/foo/baz/biz/buz/bar/everything/else/here'), + {'baz':'baz', 'buz':'buz', + 'remainder':'/everything/else/here'}) + self.assertEqual(matcher('foo/baz/biz/buz/bar'), None) + self.assertEqual(generator( + {'baz':1, 'buz':2, 'remainder':'/a/b'}), '/foo/1/biz/2/bar%2Fa%2Fb') def test_no_beginning_slash(self): matcher, generator = self._callFUT('foo/:baz/biz/:buz/bar') diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py index 0f8691a07..5d1e53947 100644 --- a/pyramid/urldispatch.py +++ b/pyramid/urldispatch.py @@ -75,6 +75,7 @@ class RoutesMapper(object): # stolen from bobo and modified old_route_re = re.compile(r'(\:[a-zA-Z]\w*)') +star_in_brackets = re.compile(r'\{[^\}]*\*\w*[^\}]*\}') route_re = re.compile(r'(\{[a-zA-Z][^\}]*\})') def update_pattern(matchobj): name = matchobj.group(0) @@ -87,7 +88,7 @@ def _compile_route(route): if not route.startswith('/'): route = '/' + route star = None - if '*' in route: + if '*' in route and not star_in_brackets.search(route): route, star = route.rsplit('*', 1) pat = route_re.split(route) pat.reverse() -- cgit v1.2.3 From 6471d307be249dc2aa22ab65128e8c2a0404ff79 Mon Sep 17 00:00:00 2001 From: John Shipman Date: Sat, 15 Jan 2011 14:45:17 -0700 Subject: General reformatting of the wiki and wiki2 tutorials to eliminate any overly long lines in the PDF rendering. Changes to .rst files: (docs/tutorials/wiki/authorization.rst) (docs/tutorials/wiki/definingviews.rst) (docs/tutorials/wiki2/authorization.rst) (docs/tutorials/wiki2/definingviews.rst) 1. For included templates, added :tab-width: 2 options. 2. wiki2/authorization.rst: Wrong markup for file names __init__.py and views.py just after the subhead "Adding security.py". Changes to .py files: Folded a few long lines. (docs/tutorials/wiki/src/basiclayout/tutorial/views.py) (docs/tutorials/wiki/src/authorization/tutorial/views.py) (docs/tutorials/wiki/src/views/tutorial/views.py) (docs/tutorials/wiki2/src/basiclayout/tutorial/models.py) (docs/tutorials/wiki2/src/models/tutorial/models.py) Changes to .pt files: Broke long lines; reformatted for 2-space indentation using tabs. (docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt) (docs/tutorials/wiki/src/authorization/tutorial/templates/login.pt) (docs/tutorials/wiki/src/authorization/tutorial/templates/view.pt) (docs/tutorials/wiki/src/views/tutorial/templates/edit.pt) (docs/tutorials/wiki/src/views/tutorial/templates/view.pt) (docs/tutorials/wiki2/src/authorization/tutorial/templates/edit.pt) (docs/tutorials/wiki2/src/authorization/tutorial/templates/login.pt) (docs/tutorials/wiki2/src/authorization/tutorial/templates/view.pt) (docs/tutorials/wiki2/src/views/tutorial/templates/edit.pt) (docs/tutorials/wiki2/src/views/tutorial/templates/view.pt) --- docs/tutorials/wiki/authorization.rst | 3 + docs/tutorials/wiki/definingviews.rst | 2 + .../src/authorization/tutorial/templates/edit.pt | 42 ++- .../src/authorization/tutorial/templates/login.pt | 38 ++- .../src/authorization/tutorial/templates/view.pt | 35 +- .../wiki/src/authorization/tutorial/views.py | 2 +- .../wiki/src/basiclayout/tutorial/views.py | 3 +- .../wiki/src/views/tutorial/templates/edit.pt | 40 ++- .../wiki/src/views/tutorial/templates/view.pt | 33 +- docs/tutorials/wiki/src/views/tutorial/views.py | 2 +- docs/tutorials/wiki2/authorization.rst | 351 ++++++++++++++++++++- docs/tutorials/wiki2/definingviews.rst | 3 + .../src/authorization/tutorial/templates/edit.pt | 42 ++- .../src/authorization/tutorial/templates/login.pt | 38 ++- .../src/authorization/tutorial/templates/view.pt | 35 +- .../wiki2/src/basiclayout/tutorial/models.py | 3 +- docs/tutorials/wiki2/src/models/tutorial/models.py | 3 +- .../wiki2/src/views/tutorial/templates/edit.pt | 40 ++- .../wiki2/src/views/tutorial/templates/view.pt | 33 +- 19 files changed, 600 insertions(+), 148 deletions(-) diff --git a/docs/tutorials/wiki/authorization.rst b/docs/tutorials/wiki/authorization.rst index ee86eb543..5e45c070e 100644 --- a/docs/tutorials/wiki/authorization.rst +++ b/docs/tutorials/wiki/authorization.rst @@ -137,6 +137,7 @@ referred to within the login view we just added to ``login.py``. .. literalinclude:: src/authorization/tutorial/templates/login.pt :language: xml + :tab-width: 2 Change ``view.pt`` and ``edit.pt`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -281,12 +282,14 @@ Our ``edit.pt`` template will look something like this when we're done: .. literalinclude:: src/authorization/tutorial/templates/edit.pt :linenos: :language: xml + :tab-width: 2 Our ``view.pt`` template will look something like this when we're done: .. literalinclude:: src/authorization/tutorial/templates/view.pt :linenos: :language: xml + :tab-width: 2 Revisiting the Application --------------------------- diff --git a/docs/tutorials/wiki/definingviews.rst b/docs/tutorials/wiki/definingviews.rst index 90768f320..7ad5e57cb 100644 --- a/docs/tutorials/wiki/definingviews.rst +++ b/docs/tutorials/wiki/definingviews.rst @@ -231,6 +231,7 @@ the below: .. literalinclude:: src/views/tutorial/templates/view.pt :language: xml + :tab-width: 2 .. note:: The names available for our use in a template are always those that are present in the dictionary returned by the view callable. But our @@ -257,6 +258,7 @@ below: .. literalinclude:: src/views/tutorial/templates/edit.pt :language: xml + :tab-width: 2 Static Assets ------------- diff --git a/docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt b/docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt index 0e5858d3b..b5fa54dec 100644 --- a/docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt +++ b/docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt @@ -1,16 +1,22 @@ - - + + - ${page.__name__} - Pyramid tutorial wiki (based on TurboGears 20-Minute Wiki) + ${page.__name__} - Pyramid tutorial wiki (based on + TurboGears 20-Minute Wiki) - - - - + + @@ -18,19 +24,22 @@
- pyramid + pyramid
- Editing Page Name Goes Here
- You can return to the FrontPage.
+ Editing Page Name + Goes Here
+ You can return to the + FrontPage.
@@ -38,9 +47,10 @@
-