From c0536d3b7487e73599b1f2ae1fcb963b91d41e8f Mon Sep 17 00:00:00 2001 From: Tim Nyborg Date: Tue, 16 Dec 2014 11:47:33 +0000 Subject: [PATCH 1/2] 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 --- gluon/rewrite.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gluon/rewrite.py b/gluon/rewrite.py index eabefc2c..23a0dac9 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -878,7 +878,10 @@ class MapUrlIn(object): self.domain_application = None self.domain_controller = 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: self.application = arg0 elif not base.exclusive_domain and arg0 and not base.applications: @@ -1256,9 +1259,9 @@ class MapUrlOut(object): "Builds a/c/f from components" acf = '' if self.map_hyphen: - self.application = self.application.replace('_', '-') self.controller = self.controller.replace('_', '-') if self.controller != 'static' and not self.controller.startswith('static/'): + self.application = self.application.replace('_', '-') self.function = self.function.replace('_', '-') if not self.omit_application: acf += '/' + self.application From 23ee6bd2cf72498ecec0b8b4f331990ca86e43a2 Mon Sep 17 00:00:00 2001 From: Tim Nyborg Date: Tue, 16 Dec 2014 12:00:23 +0000 Subject: [PATCH 2/2] Update rewrite.py --- gluon/rewrite.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gluon/rewrite.py b/gluon/rewrite.py index 23a0dac9..661a0d27 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -878,10 +878,8 @@ class MapUrlIn(object): self.domain_application = None self.domain_controller = None self.domain_function = None - if base.map_hyphen: - arg0 = self.harg0.replace('-', '_') - else: - arg0 = self.harg0 + self.map_hyphen = base.map_hyphen + arg0 = self.harg0 if not base.exclusive_domain and base.applications and arg0 in base.applications: self.application = arg0 elif not base.exclusive_domain and arg0 and not base.applications: