Allow map_hyphen to work for application names

1. Handle hyphen -> underscore replacement of the app name early in map_app(), so the application can be identified and its routing rules used (if they exist).  Without this, the rewriter fails to find the application with the hyphen in place, and reverts to the default.

2. Disable underscore -> hyphen mapping of app name when creating static URLs, as they will be invalid paths
This commit is contained in:
Tim Nyborg
2014-12-16 11:47:33 +00:00
parent 5ea654ed06
commit c0536d3b74
+5 -2
View File
@@ -878,7 +878,10 @@ class MapUrlIn(object):
self.domain_application = None self.domain_application = None
self.domain_controller = None self.domain_controller = None
self.domain_function = None self.domain_function = None
arg0 = self.harg0 if base.map_hyphen:
arg0 = self.harg0.replace('-', '_')
else:
arg0 = self.harg0
if not base.exclusive_domain and base.applications and arg0 in base.applications: if not base.exclusive_domain and base.applications and arg0 in base.applications:
self.application = arg0 self.application = arg0
elif not base.exclusive_domain and arg0 and not base.applications: elif not base.exclusive_domain and arg0 and not base.applications:
@@ -1256,9 +1259,9 @@ class MapUrlOut(object):
"Builds a/c/f from components" "Builds a/c/f from components"
acf = '' acf = ''
if self.map_hyphen: if self.map_hyphen:
self.application = self.application.replace('_', '-')
self.controller = self.controller.replace('_', '-') self.controller = self.controller.replace('_', '-')
if self.controller != 'static' and not self.controller.startswith('static/'): if self.controller != 'static' and not self.controller.startswith('static/'):
self.application = self.application.replace('_', '-')
self.function = self.function.replace('_', '-') self.function = self.function.replace('_', '-')
if not self.omit_application: if not self.omit_application:
acf += '/' + self.application acf += '/' + self.application