From d468d5b5928f1e1552017bf02797a77acc72c40f Mon Sep 17 00:00:00 2001 From: Moriyoshi Koizumi Date: Sun, 17 Jul 2016 04:15:23 +0900 Subject: [PATCH] Add --paste-global-conf option (#1304) * Add --paste-global-conf option so users can pass arbitrary values to the PasteDeploy entrypoint from cli * Reflect the suggestions: `--paste-global-conf` => `--paste-global` and adding more description in the docstring. --- gunicorn/app/wsgiapp.py | 2 +- gunicorn/config.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/gunicorn/app/wsgiapp.py b/gunicorn/app/wsgiapp.py index cf4db1ebd..aeb15bbc5 100644 --- a/gunicorn/app/wsgiapp.py +++ b/gunicorn/app/wsgiapp.py @@ -56,7 +56,7 @@ def load_pasteapp(self): # load the paste app from .pasterapp import load_pasteapp - return load_pasteapp(self.cfgurl, self.relpath, global_conf=None) + return load_pasteapp(self.cfgurl, self.relpath, global_conf=self.cfg.paste_global_conf) def load(self): if self.cfg.paste is not None: diff --git a/gunicorn/config.py b/gunicorn/config.py index 740d8e506..60fcd3de1 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -14,6 +14,7 @@ from . import argparse_compat as argparse import os import pwd +import re import ssl import sys import textwrap @@ -203,6 +204,25 @@ def sendfile(self): return True + @property + def paste_global_conf(self): + raw_global_conf = self.settings['raw_paste_global_conf'].get() + if raw_global_conf is None: + return None + + global_conf = {} + for e in raw_global_conf: + s = _compat.bytes_to_str(e) + try: + k, v = re.split(r'(?