From 170c66b00020ce88f094abef8ce6c15b3fa86a16 Mon Sep 17 00:00:00 2001 From: "roberto@maverick64" Date: Thu, 13 Jan 2011 18:10:13 +0100 Subject: [PATCH] fixed paste support: Plone threaded works perfectly --- plugins/python/pyloader.c | 11 +++-------- plugins/python/python_plugin.c | 22 ++++++++++++++++------ plugins/python/uwsgi_python.h | 2 -- plugins/python/wsgi_handlers.c | 2 -- uwsgi.c | 28 ---------------------------- 5 files changed, 19 insertions(+), 46 deletions(-) diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index 09b69841..eef6c92c 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -407,11 +407,9 @@ PyObject *uwsgi_mount_loader(void *arg1) { if ( !strcmp(what+strlen(what)-3, ".py") || !strcmp(what+strlen(what)-5, ".wsgi")) { callable = uwsgi_file_loader((void *)what); } -#ifdef UWSGI_PASTE else if (!strcmp(what+strlen(what)-4, ".ini")) { callable = uwsgi_paste_loader((void *)what); } -#endif else if (strchr(what, ':')) { callable = uwsgi_uwsgi_loader((void *)what); } @@ -451,14 +449,14 @@ PyObject *uwsgi_dyn_loader(void *arg1) { callable = uwsgi_file_loader((void *)tmpstr); free(tmpstr); } -#ifdef UWSGI_PASTE - // MANAGE UWSGI_PASTE + // TODO MANAGE UWSGI_PASTE +/* else if (wsgi_req->wsgi_paste_len > 0) { tmpstr = uwsgi_strncopy(wsgi_req->paste, wsgi_req->paste_len); callable = uwsgi_paste_loader((void *)tmpstr); free(tmpstr); } -#endif +*/ return callable; } @@ -496,7 +494,6 @@ PyObject *uwsgi_file_loader(void *arg1) { } -#ifdef UWSGI_PASTE PyObject *uwsgi_paste_loader(void *arg1) { char *paste = (char *) arg1; @@ -543,8 +540,6 @@ PyObject *uwsgi_paste_loader(void *arg1) { return paste_app; } -#endif - PyObject *uwsgi_eval_loader(void *arg1) { char *code = (char *) arg1; diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 686b666a..514d3d84 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -17,11 +17,9 @@ struct option uwsgi_python_options[] = { {"pp", required_argument, 0, LONG_ARGS_PYTHONPATH}, {"pyargv", required_argument, 0, LONG_ARGS_PYARGV}, {"optimize", required_argument, 0, 'O'}, -#ifdef UWSGI_PASTE {"paste", required_argument, 0, LONG_ARGS_PASTE}, #ifdef UWSGI_INI {"ini-paste", required_argument, 0, LONG_ARGS_INI_PASTE}, -#endif #endif {"catch-exceptions", no_argument, &up.catch_exceptions, 1}, {"ignore-script-name", no_argument, &up.ignore_script_name, 1}, @@ -112,9 +110,7 @@ int uwsgi_python_init() { #endif up.loaders[LOADER_UWSGI] = uwsgi_uwsgi_loader; up.loaders[LOADER_FILE] = uwsgi_file_loader; -#ifdef UWSGI_PASTE up.loaders[LOADER_PASTE] = uwsgi_paste_loader; -#endif up.loaders[LOADER_EVAL] = uwsgi_eval_loader; up.loaders[LOADER_MOUNT] = uwsgi_mount_loader; up.loaders[LOADER_CALLABLE] = uwsgi_callable_loader; @@ -631,6 +627,22 @@ int uwsgi_python_magic(char *mountpoint, char *lazy) { case LONG_ARGS_CALLABLE: up.callable = optarg; return 1; + + + case LONG_ARGS_INI_PASTE: + uwsgi.ini = optarg; + if (uwsgi.ini[0] != '/') { + up.paste = uwsgi_concat4("config:", uwsgi.cwd, "/", uwsgi.ini); + } else { + up.paste = uwsgi_concat2("config:", uwsgi.ini); + } + return 1; + case LONG_ARGS_PASTE: + up.paste = optarg; + return 1; + + + } return 0; @@ -656,11 +668,9 @@ int uwsgi_python_mount_app(char *mountpoint, char *app) { if (up.file_config != NULL) { init_uwsgi_app(LOADER_FILE, up.file_config, uwsgi.wsgi_req, up.main_thread); } -#ifdef UWSGI_PASTE if (up.paste != NULL) { init_uwsgi_app(LOADER_PASTE, up.paste, uwsgi.wsgi_req, up.main_thread); } -#endif if (up.eval != NULL) { init_uwsgi_app(LOADER_EVAL, up.eval, uwsgi.wsgi_req, up.main_thread); } diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index 791fe1e1..e4296179 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -135,9 +135,7 @@ void init_uwsgi_embedded_module(void); void uwsgi_wsgi_config(char *); -#ifdef UWSGI_PASTE void uwsgi_paste_config(char *); -#endif void uwsgi_file_config(char *); void uwsgi_eval_config(char *); diff --git a/plugins/python/wsgi_handlers.c b/plugins/python/wsgi_handlers.c index ccb9055a..24d9d7c7 100644 --- a/plugins/python/wsgi_handlers.c +++ b/plugins/python/wsgi_handlers.c @@ -143,9 +143,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) { if (wsgi_req->script_len > 0 || wsgi_req->module_len > 0 || wsgi_req->file_len > 0 -#ifdef UWSGI_PASTE || wsgi_req->paste_len > 0 -#endif ) { // a bit of magic: 1-1 = 0 / 0-1 = -1 // this part must be heavy locked in threaded modes diff --git a/uwsgi.c b/uwsgi.c index c73d7d56..3f8ef52b 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -1890,34 +1890,6 @@ end: case LONG_ARGS_INI: uwsgi.ini = optarg; return 1; -/* - case LONG_ARGS_EVAL_CONFIG: - uwsgi.eval = optarg; - return 1; -*/ -#ifdef UWSGI_PASTE - case LONG_ARGS_INI_PASTE: - uwsgi.ini = optarg; - if (uwsgi.ini[0] != '/') { - uwsgi.paste = uwsgi_malloc(7 + strlen(uwsgi.cwd) + 1 + strlen(uwsgi.ini) + 1); - memset(uwsgi.paste, 0, 7 + strlen(uwsgi.cwd) + strlen(uwsgi.ini) + 1); - memcpy(uwsgi.paste, "config:", 7); - memcpy(uwsgi.paste + 7, uwsgi.cwd, strlen(uwsgi.cwd)); - uwsgi.paste[7 + strlen(uwsgi.cwd)] = '/'; - memcpy(uwsgi.paste + 7 + strlen(uwsgi.cwd) + 1, uwsgi.ini, strlen(uwsgi.ini)); - } else { - uwsgi.paste = uwsgi_malloc(7 + strlen(uwsgi.ini) + 1); - memset(uwsgi.paste, 0, 7 + strlen(uwsgi.ini) + 1); - memcpy(uwsgi.paste, "config:", 7); - memcpy(uwsgi.paste + 7, uwsgi.ini, strlen(uwsgi.ini)); - } - return 1; -#endif -#endif -#ifdef UWSGI_PASTE - case LONG_ARGS_PASTE: - uwsgi.paste = optarg; - return 1; #endif case LONG_ARGS_CHECK_INTERVAL: uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL] = atoi(optarg);