pyramid/config/testing.py | ●●●●● patch | view | raw | blame | history | |
pyramid/config/util.py | ●●●●● patch | view | raw | blame | history | |
pyramid/traversal.py | ●●●●● patch | view | raw | blame | history |
pyramid/config/testing.py
@@ -8,7 +8,11 @@ ) from pyramid.renderers import RendererHelper from pyramid.traversal import traversal_path_info from pyramid.traversal import ( decode_path_info, split_path_info, ) from pyramid.config.util import action_method @@ -66,9 +70,9 @@ self.context = context def __call__(self, request): path = request.environ['PATH_INFO'] path = decode_path_info(request.environ['PATH_INFO']) ob = resources[path] traversed = traversal_path_info(path) traversed = split_path_info(path) return {'context':ob, 'view_name':'','subpath':(), 'traversed':traversed, 'virtual_root':ob, 'virtual_root_path':(), 'root':ob} pyramid/config/util.py
@@ -15,7 +15,7 @@ from pyramid.traversal import ( find_interface, traversal_path_info, traversal_path, ) from hashlib import md5 @@ -268,8 +268,8 @@ if 'traverse' in context: return True m = context['match'] tvalue = tgenerate(m) m['traverse'] = traversal_path_info(tvalue) tvalue = tgenerate(m) # tvalue will be urlquoted string m['traverse'] = traversal_path(tvalue) # will be seq of unicode return True # This isn't actually a predicate, it's just a infodict # modifier that injects ``traverse`` into the matchdict. As a pyramid/traversal.py
@@ -438,11 +438,12 @@ not. A :exc:`UnicodeEncodeError` will be raised if the Unicode cannot be encoded directly to ASCII. """ # we unquote this path exactly like a PEP 3333 server would if isinstance(path, text_type): # must not possess characters outside ascii path = path.encode('ascii') # we unquote this path exactly like a PEP 3333 server would path = unquote_bytes_to_wsgi(path) # result will be a native string return traversal_path_info(path) return traversal_path_info(path) # result will be a tuple of unicode @lru_cache(1000) def traversal_path_info(path): @@ -516,15 +517,15 @@ applications in :app:`Pyramid`. """ try: path = decode_path_info(path) path = decode_path_info(path) # result will be Unicode except UnicodeDecodeError as e: raise URLDecodeError(e.encoding, e.object, e.start, e.end, e.reason) return split_path_info(path) return split_path_info(path) # result will be tuple of Unicode @lru_cache(1000) def split_path_info(path): # suitable for splitting an already-unquoted-already-decoded path_info # string # suitable for splitting an already-unquoted-already-decoded (unicode) # path value path = path.strip('/') clean = [] for segment in path.split('/'):