From 5baffe51582c9d39aa4911a37a098c2a20e69d88 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Fri, 20 Sep 2024 11:23:43 +0200 Subject: [PATCH 1/2] Fix wsgi_ini_template creation when recipe is called multiple times in buildout --- src/plone/recipe/zope2instance/recipe.py | 15 +++++++++------ .../zope2instance/tests/test_wsgi_template.py | 6 ++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plone/recipe/zope2instance/recipe.py b/src/plone/recipe/zope2instance/recipe.py index 6a752c4..7db1a04 100644 --- a/src/plone/recipe/zope2instance/recipe.py +++ b/src/plone/recipe/zope2instance/recipe.py @@ -116,6 +116,11 @@ def __init__(self, buildout, name, options): zope """.strip() ) + + # instantinate base wsgi_ini_template + global wsgi_ini_template + self._wsgi_ini_template = wsgi_ini_template + # Get Scripts' attributes return Scripts.__init__(self, buildout, name, options) @@ -924,13 +929,11 @@ def build_wsgi_ini(self): "cannot be used together." ) - global wsgi_ini_template - # Load custom wsgi and logging template from file if wsgi_ini_template_path: try: with open(wsgi_ini_template_path) as fp: - wsgi_ini_template = fp.read() + self._wsgi_ini_template = fp.read() except OSError: raise @@ -939,14 +942,14 @@ def build_wsgi_ini(self): try: with open(wsgi_logging_ini_template_path) as fp: # Add custom wsgi logging template to wsgi template - wsgi_ini_template += fp.read() + self._wsgi_ini_template += fp.read() except OSError: raise # Load default global wsgi and logging template else: global wsgi_logging_ini_template - wsgi_ini_template += wsgi_logging_ini_template + self._wsgi_ini_template += wsgi_logging_ini_template # generate a different [server:main] - useful for Windows wsgi_server_main_template = wsgi_server_main_templates.get( @@ -954,7 +957,7 @@ def build_wsgi_ini(self): ) wsgi_options["server_main"] = wsgi_server_main_template % wsgi_options - wsgi_ini = wsgi_ini_template % wsgi_options + wsgi_ini = self._wsgi_ini_template % wsgi_options # Catch errors in generated wsgi.ini by parsing it before writing the file configparser.ConfigParser().read_string(wsgi_ini) diff --git a/src/plone/recipe/zope2instance/tests/test_wsgi_template.py b/src/plone/recipe/zope2instance/tests/test_wsgi_template.py index 2467ae8..425fa32 100644 --- a/src/plone/recipe/zope2instance/tests/test_wsgi_template.py +++ b/src/plone/recipe/zope2instance/tests/test_wsgi_template.py @@ -35,6 +35,12 @@ def test_wsgi_ini_template(self): eggs = user = me:me wsgi-ini-template = %(sample_buildout)s/wsgi_tmpl.ini + +[instance2] +# check multiple recipe call +recipe = plone.recipe.zope2instance +eggs = +user = me:me """ TEMPLATE_CONTENT = """ [section] From 6acf6f06b393b4770db1d7378789df3774dc5197 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Fri, 20 Sep 2024 11:27:33 +0200 Subject: [PATCH 2/2] add changenote --- news/197.bugfix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 news/197.bugfix diff --git a/news/197.bugfix b/news/197.bugfix new file mode 100644 index 0000000..9317683 --- /dev/null +++ b/news/197.bugfix @@ -0,0 +1,2 @@ +Fix wsgi_ini_template creation when recipe is called multiple times. +[petschki]