From 5a0f3981190a3e1d31f7464661f0560eb5f21646 Mon Sep 17 00:00:00 2001 From: Mikhail Feoktistov Date: Fri, 13 Nov 2020 10:44:58 +0000 Subject: [PATCH 1/2] Use the absolute path to the configuration file This fixes issues when PYTHONPATH contains multiple mamba based projects We have: PYTHONPAHT=project-1:project-2 Issue: If we run `project-2: $ twistd project-2`, twistd MIGHT start/pickup project-1 because project-1 has `project-2` tapname read from project-2/config/application.json because it's in $PWD. @see https://github.com/twisted/twisted/blob/trunk/src/twisted/application/app.py#L654-L666 --- mamba/templates/plugin.tpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mamba/templates/plugin.tpl b/mamba/templates/plugin.tpl index 89884bd..1237285 100644 --- a/mamba/templates/plugin.tpl +++ b/mamba/templates/plugin.tpl @@ -1,3 +1,5 @@ +from os.path import abspath, dirname, join + from zope.interface import implements from twisted.python import usage @@ -13,8 +15,8 @@ from mamba.core.services.herokuservice import HerokuService from mamba.core.services.threadpool import ThreadPoolService from ${application} import MambaApplicationFactory - -settings = config.Application('config/${file}') +cfg = abspath(join(dirname(__file__), '..', '..', 'config/${file}')) +settings = config.Application(cfg) class Options(usage.Options): From 2d2ef25c01a6e46fa4c0753333aca8b38d1352b1 Mon Sep 17 00:00:00 2001 From: Mikhail Feoktistov Date: Fri, 13 Nov 2020 10:48:39 +0000 Subject: [PATCH 2/2] Comment --- mamba/templates/plugin.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/mamba/templates/plugin.tpl b/mamba/templates/plugin.tpl index 1237285..9aca804 100644 --- a/mamba/templates/plugin.tpl +++ b/mamba/templates/plugin.tpl @@ -15,6 +15,7 @@ from mamba.core.services.herokuservice import HerokuService from mamba.core.services.threadpool import ThreadPoolService from ${application} import MambaApplicationFactory +# the config path is relative to ${app}/twisted/plugins cfg = abspath(join(dirname(__file__), '..', '..', 'config/${file}')) settings = config.Application(cfg)