From bbde0c866a09f266f0b7d52ef7c94d028780e71e Mon Sep 17 00:00:00 2001 From: "roberto@dexter" Date: Wed, 24 Aug 2011 17:48:27 +0200 Subject: [PATCH] a couple of fixes, and reintroduction of string-based multiapp --- plugins/python/pyloader.c | 22 +++++++++++++++++++++- plugins/python/symimporter.c | 10 ++++++---- protocol.c | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index f2c67002..604284f5 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -170,8 +170,16 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre wi->mountpoint_len = strlen(wi->mountpoint); wsgi_req->appid = wi->mountpoint; wsgi_req->appid_len = wi->mountpoint_len; +#ifdef UWSGI_DEBUG uwsgi_log("main mountpoint = %s\n", wi->mountpoint); +#endif wi->callable = PyDict_GetItem(applications, app_mnt); + if (PyString_Check((PyObject *) wi->callable)) { + PyObject *callables_dict = get_uwsgi_pydict((char *)arg1); + if (callables_dict) { + wi->callable = PyDict_GetItem(callables_dict, (PyObject *)wi->callable); + } + } } Py_INCREF((PyObject *)wi->callable); @@ -329,7 +337,19 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre wsgi_req->appid = PyString_AsString(app_mnt); wsgi_req->appid_len = strlen(wsgi_req->appid); - init_uwsgi_app(LOADER_CALLABLE, PyDict_GetItem(applications, app_mnt), wsgi_req, wi->interpreter, app_type); + PyObject *a_callable = PyDict_GetItem(applications, app_mnt); + if (PyString_Check(a_callable)) { + + PyObject *callables_dict = get_uwsgi_pydict((char *)arg1); + if (callables_dict) { + a_callable = PyDict_GetItem(callables_dict, a_callable); + } + } + if (!a_callable) { + uwsgi_log("skipping broken app %s\n", wsgi_req->appid); + continue; + } + init_uwsgi_app(LOADER_CALLABLE, a_callable, wsgi_req, wi->interpreter, app_type); } } diff --git a/plugins/python/symimporter.c b/plugins/python/symimporter.c index 3309ae2a..63262ba4 100644 --- a/plugins/python/symimporter.c +++ b/plugins/python/symimporter.c @@ -351,13 +351,15 @@ clear: } static PyMethodDef symimporter_methods[] = { - {"find_module", symimporter_find_module, METH_VARARGS}, - {"load_module", symimporter_load_module, METH_VARARGS}, + {"find_module", symimporter_find_module, METH_VARARGS}, + {"load_module", symimporter_load_module, METH_VARARGS}, + { NULL, NULL }, }; static PyMethodDef symzipimporter_methods[] = { - {"find_module", symzipimporter_find_module, METH_VARARGS}, - {"load_module", symzipimporter_load_module, METH_VARARGS}, + {"find_module", symzipimporter_find_module, METH_VARARGS}, + {"load_module", symzipimporter_load_module, METH_VARARGS}, + { NULL, NULL }, }; static void uwsgi_symimporter_free(struct _symimporter *self) { diff --git a/protocol.c b/protocol.c index 18ad06f3..d2f7f554 100644 --- a/protocol.c +++ b/protocol.c @@ -767,7 +767,7 @@ next: script_name = wsgi_req->var_cnt; } for(i=0;i= uwsgi_apps[i].mountpoint_len) { if (!uwsgi_startswith(orig_path_info, uwsgi_apps[i].mountpoint, uwsgi_apps[i].mountpoint_len) && uwsgi_apps[i].mountpoint_len > best_found) { best_found = uwsgi_apps[i].mountpoint_len;