From 0193ad192f5a52052a1ce39a66c11f48bfaa9ad9 Mon Sep 17 00:00:00 2001 From: Wynn Wilkes Date: Tue, 12 Nov 2019 10:21:57 -0700 Subject: [PATCH 1/2] crash fix when using a custom dmp_path regex - This prevents a crash if the dmp_path regex captures a None value for the dmp_urlparams matching group. A regex like: ^(org\.(?P[_a-zA-Z0-9\-]+)/)?(?P[_a-zA-Z0-9\-]+)(\.?P[_a-zA-Z0-9\.\-]+)?/(?P.+?)?$ for a path like: org.agency-1/agent_dashboard/ would result in the crash. --- django_mako_plus/router/resolver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_mako_plus/router/resolver.py b/django_mako_plus/router/resolver.py index 492af95d..ae5020f7 100755 --- a/django_mako_plus/router/resolver.py +++ b/django_mako_plus/router/resolver.py @@ -193,7 +193,7 @@ def resolve(self, path): match.kwargs.pop('dmp_app', None) or self.dmp.options['DEFAULT_APP'], match.kwargs.pop('dmp_page', None) or self.dmp.options['DEFAULT_PAGE'], match.kwargs.pop('dmp_function', None) or 'process_request', - match.kwargs.pop('dmp_urlparams', '').strip(), + (match.kwargs.pop('dmp_urlparams', None) or '').strip(), ) if VERSION < (2, 2): return ResolverMatch( From 8a33eb3911fc84ddddd590152f475fd78c6a501f Mon Sep 17 00:00:00 2001 From: Wynn Wilkes Date: Tue, 7 Jan 2020 20:40:07 -0700 Subject: [PATCH 2/2] Do a log.exception when there's a crash on your dmp_path configuration - This avoids silent errors when a view has a syntax error or other failure that causes it to not import. --- django_mako_plus/router/resolver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_mako_plus/router/resolver.py b/django_mako_plus/router/resolver.py index ae5020f7..c32e7ae8 100755 --- a/django_mako_plus/router/resolver.py +++ b/django_mako_plus/router/resolver.py @@ -218,7 +218,7 @@ def resolve(self, path): # this is a hack, but the resolver error page doesn't give other options. # the sad face is to catch the dev's attention in Django's printout msg = "◉︵◉ Pattern matched, but discovery failed: {}".format(vdne) - log.debug("%s %s", match.url_name, msg) + log.exception("%s %s", match.url_name, msg) raise Resolver404({ # this is a bit convoluted, but it makes the PatternStub work with Django 1.x and 2.x 'tried': [[ PatternStub(match.url_name, msg, PatternStub(match.url_name, msg, None)) ]],