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
{{ message }}
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
The simplest form of URI route in webapp2 is a tuple (regex, handler), where regex is a regular expression to match the requested URI path and handler is a callable to handle the request.
This is not true. regex is, in fact, a template, not a Python regex.
This is what happens if you try to use a Python regex as the regex part of the tuple:
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 267, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1240, in default_dispatcher
route, args, kwargs = rv = self.match(request)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1180, in default_matcher
match = route.match(request)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 825, in match
match = self.regex.match(urllib.unquote(request.path))
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 701, in __get__
value = self.func(obj)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/277b61042b697c7a_unzipped/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 812, in regex
if not self.template.startswith('^'):
AttributeError: '_sre.SRE_Pattern' object has no attribute 'startswith'
The text was updated successfully, but these errors were encountered:
The docs for
webapp2.Router.__init__()
andadd()
are misleading:In fact, a simple route tuple is of the form
(template, handler)
. It does not take a regex, as in something returned byre.compile()
.The documentation for simple route is also misleading:
This is not true.
regex
is, in fact, a template, not a Python regex.This is what happens if you try to use a Python regex as the
regex
part of the tuple:The text was updated successfully, but these errors were encountered: