[Checkins] SVN: bobo/trunk/bobo Fixed a bug in URL matching in subroutes.
Jim Fulton
jim at zope.com
Mon Jan 18 16:38:05 EST 2010
Log message for revision 108236:
Fixed a bug in URL matching in subroutes.
Changed:
U bobo/trunk/bobo/src/bobo.py
U bobo/trunk/bobodoctestumentation/src/bobodoctestumentation/decorator.test
-=-
Modified: bobo/trunk/bobo/src/bobo.py
===================================================================
--- bobo/trunk/bobo/src/bobo.py 2010-01-18 21:12:31 UTC (rev 108235)
+++ bobo/trunk/bobo/src/bobo.py 2010-01-18 21:38:04 UTC (rev 108236)
@@ -946,8 +946,6 @@
if m is None:
return m
path = path[len(m.group(0)):]
- if path and not path.startswith('/'):
- path = '/'+path
return (dict(item for item in m.groupdict().iteritems()
if item[1] is not None),
path,
Modified: bobo/trunk/bobodoctestumentation/src/bobodoctestumentation/decorator.test
===================================================================
--- bobo/trunk/bobodoctestumentation/src/bobodoctestumentation/decorator.test 2010-01-18 21:12:31 UTC (rev 108235)
+++ bobo/trunk/bobodoctestumentation/src/bobodoctestumentation/decorator.test 2010-01-18 21:38:04 UTC (rev 108236)
@@ -63,7 +63,7 @@
{}
>>> test('/', '/foo')
>>> test('/', '/foo', partial=True)
- '/foo'
+ 'foo'
{}
>>> test('/foo', '/foo')
{}
@@ -72,6 +72,9 @@
{}
>>> test('/foo/', '/foo/bar')
>>> test('/foo/', '/foo/bar', '/bar')
+ 'bar'
+ {}
+ >>> test('/foo', '/foo/bar', '/bar')
'/bar'
{}
{}
@@ -859,3 +862,28 @@
>>> bobo._make_bobo_handle = original_make_bobo_handle
>>> bobo._compile_route = original_compile_route
+
+check we don't match within path segment prefixes
+-------------------------------------------------
+
+ >>> @bobo.subroute('/events', scan=True)
+ ... class Events:
+ ...
+ ... def __init__(self, request): pass
+ ...
+ ... @bobo.query('')
+ ... def base(self, bobo_request):
+ ... return 'id '+self.id
+ ...
+ ... @bobo.subroute('/:id')
+ ... def event_page(self, request, id):
+ ... self.id = id
+ ... return self
+
+ >>> call_resource(Events, '/eventswaaa')
+ >>> call_resource(Events, '/events/1')
+ BoboException:
+ {'body': 'id 1',
+ 'content_type': 'text/html; charset=UTF-8',
+ 'headers': [],
+ 'status': 200}
More information about the checkins
mailing list