diff --git a/news/197.bugfix b/news/197.bugfix new file mode 100644 index 00000000..9317683b --- /dev/null +++ b/news/197.bugfix @@ -0,0 +1,2 @@ +Fix wsgi_ini_template creation when recipe is called multiple times. +[petschki] diff --git a/src/plone/recipe/zope2instance/recipe.py b/src/plone/recipe/zope2instance/recipe.py index 6a752c47..7db1a045 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 2467ae8e..425fa32c 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]