You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can run this with twistd -n web --class resource.Root. Trying to visit /foo/ results in the following traceback:
2015-09-22 19:03:11+0200 [HTTPChannel,1,127.0.0.1] Unhandled Error
Traceback (most recent call last):
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/web/server.py", line 234, in render
body = resrc.render(self)
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/web/util.py", line 139, in render
self.d.addCallback(self._cbChild, request).addErrback(
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 317, in addCallback
callbackKeywords=kw)
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 306, in addCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/web/util.py", line 145, in _cbChild
request.render(resource.getChildForRequest(child, request))
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/twisted/web/server.py", line 234, in render
body = resrc.render(self)
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/txspinneret/resource.py", line 183, in render
result = self._wrappedResource.render(request)
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/txspinneret/route.py", line 238, in render
result, segments = self._matchRoute(request, [])
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/txspinneret/route.py", line 229, in _matchRoute
matches, remaining = route(request, segments)
File "/home/mithrandi/deployment/virtualenvs/tempenv-2c7834670678/local/lib/python2.7/site-packages/txspinneret/route.py", line 113, in _matchRoute
if components[0] == '/':
exceptions.IndexError: string index out of range
Funnily enough, the same happens if you try to visit /foo. Changing the route matcher to route('/') fixes both exceptions (the former returning the expected string, and the latter returning 404, all as expected).
The text was updated successfully, but these errors were encountered:
Edited the gist slightly to demonstrate both working and broken cases at the same time; fetching /working/ should work, and fetching /broken/ produces a traceback like the above.
The documentation seems to indicate that
route('')
androute('/')
should mean the same thing, and in fact the''
version seems to make more sense to me. However, it doesn't appear to actually work, as this gist demonstrates: https://gist.github.com/mithrandi/d72ff26f86de69cdb40eYou can run this with
twistd -n web --class resource.Root
. Trying to visit/foo/
results in the following traceback:Funnily enough, the same happens if you try to visit
/foo
. Changing the route matcher toroute('/')
fixes both exceptions (the former returning the expected string, and the latter returning 404, all as expected).The text was updated successfully, but these errors were encountered: