From 1b8920393233b95d480e00279fac89ee40451818 Mon Sep 17 00:00:00 2001 From: Unbit Date: Thu, 4 Apr 2013 11:03:26 +0200 Subject: [PATCH] prepare for language independent home concept --- core/protocol.c | 10 ++++++++-- plugins/python/pyloader.c | 10 +++++----- uwsgi.h | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/core/protocol.c b/core/protocol.c index 86da9ed7..b25d9b77 100644 --- a/core/protocol.c +++ b/core/protocol.c @@ -312,6 +312,12 @@ static int uwsgi_proto_check_10(struct wsgi_request *wsgi_req, char *key, char * return 0; } + if (!uwsgi_proto_key("UWSGI_HOME", 10)) { + wsgi_req->home = buf; + wsgi_req->home_len = len; + return 0; + } + return 0; } @@ -416,8 +422,8 @@ static int uwsgi_proto_check_12(struct wsgi_request *wsgi_req, char *key, char * } if (!uwsgi_proto_key("UWSGI_PYHOME", 12)) { - wsgi_req->pyhome = buf; - wsgi_req->pyhome_len = len; + wsgi_req->home = buf; + wsgi_req->home_len = len; return 0; } diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index 5ccdb9e4..32eedea4 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -33,12 +33,12 @@ void set_dyn_pyhome(char *home, uint16_t pyhome_len) { } // simulate a pythonhome directive - if (uwsgi.wsgi_req->pyhome_len > 0) { + if (uwsgi.wsgi_req->home_len > 0) { - PyObject *venv_path = UWSGI_PYFROMSTRINGSIZE(uwsgi.wsgi_req->pyhome, uwsgi.wsgi_req->pyhome_len); + PyObject *venv_path = UWSGI_PYFROMSTRINGSIZE(uwsgi.wsgi_req->home, uwsgi.wsgi_req->home_len); #ifdef UWSGI_DEBUG - uwsgi_debug("setting dynamic virtualenv to %.*s\n", uwsgi.wsgi_req->pyhome_len, uwsgi.wsgi_req->pyhome); + uwsgi_debug("setting dynamic virtualenv to %.*s\n", uwsgi.wsgi_req->home_len, uwsgi.wsgi_req->home); #endif PyDict_SetItemString(pysys_dict, "prefix", venv_path); @@ -177,8 +177,8 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre wi->interpreter = up.main_thread; } - if (wsgi_req->pyhome_len) { - set_dyn_pyhome(wsgi_req->pyhome, wsgi_req->pyhome_len); + if (wsgi_req->home_len) { + set_dyn_pyhome(wsgi_req->home, wsgi_req->home_len); } if (wsgi_req->touch_reload_len > 0 && wsgi_req->touch_reload_len < 0xff) { diff --git a/uwsgi.h b/uwsgi.h index 59a6d463..37371b00 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -1265,8 +1265,8 @@ struct uwsgi_router { uint16_t module_len; char *callable; uint16_t callable_len; - char *pyhome; - uint16_t pyhome_len; + char *home; + uint16_t home_len; char *file; uint16_t file_len;