##// END OF EJS Templates
routing: fix default argument mutability.
marcink -
r3091:7a298dcc default
parent child Browse files
Show More
@@ -61,12 +61,13 b' def add_route_with_slash(config,name, pa'
61 config.add_route(name + '_slash', pattern + '/', **kw)
61 config.add_route(name + '_slash', pattern + '/', **kw)
62
62
63
63
64 def add_route_requirements(route_path, requirements=URL_NAME_REQUIREMENTS):
64 def add_route_requirements(route_path, requirements=None):
65 """
65 """
66 Adds regex requirements to pyramid routes using a mapping dict
66 Adds regex requirements to pyramid routes using a mapping dict
67 e.g::
67 e.g::
68 add_route_requirements('{repo_name}/settings')
68 add_route_requirements('{repo_name}/settings')
69 """
69 """
70 requirements = requirements or URL_NAME_REQUIREMENTS
70 for key, regex in requirements.items():
71 for key, regex in requirements.items():
71 route_path = route_path.replace('{%s}' % key, '{%s:%s}' % (key, regex))
72 route_path = route_path.replace('{%s}' % key, '{%s:%s}' % (key, regex))
72 return route_path
73 return route_path
General Comments 0
You need to be logged in to leave comments. Login now