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 committed 2014-12-16 11:47:33 +00:00
1 parent 5ea654ed06
commit c0536d3b74
1 file changed
+4 -1
+4 -1
View File
@@ -878,6 +878,9 @@ 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
if base.map_hyphen:
arg0 = self.harg0.replace('-', '_')
else:
arg0 = self.harg0 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
@@ -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