From 207979580a29f3337102e1c1a2a622f2f41e41ed Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Sun, 18 Sep 2011 07:04:36 +0200 Subject: [PATCH] added uwsgi.extract --- bootstrap5.py | 3 +++ plugins/python/uwsgi_pymodule.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 bootstrap5.py diff --git a/bootstrap5.py b/bootstrap5.py new file mode 100644 index 00000000..340e6889 --- /dev/null +++ b/bootstrap5.py @@ -0,0 +1,3 @@ +import uwsgi + +print uwsgi.extract("data://0") diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index d9c940da..38e7b4d3 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -1050,6 +1050,26 @@ PyObject *py_uwsgi_embedded_data(PyObject * self, PyObject * args) { } +PyObject *py_uwsgi_extract(PyObject * self, PyObject * args) { + + char *name; + int len; + char *buf; + + if (!PyArg_ParseTuple(args, "s:extract", &name)) { + return NULL; + } + + buf = uwsgi_open_and_read(name, &len, 0, NULL); + if (buf && len > 0) { + return PyString_FromStringAndSize(buf, len); + } + Py_INCREF(Py_None); + return Py_None; + +} + + PyObject *py_uwsgi_sharedarea_inclong(PyObject * self, PyObject * args) { uint64_t pos = 0; uint64_t value = 1; @@ -2734,6 +2754,7 @@ static PyMethodDef uwsgi_advanced_methods[] = { {"parsefile", py_uwsgi_parse_file, METH_VARARGS, ""}, {"embedded_data", py_uwsgi_embedded_data, METH_VARARGS, ""}, + {"extract", py_uwsgi_extract, METH_VARARGS, ""}, //{"call_hook", py_uwsgi_call_hook, METH_VARARGS, ""}, {NULL, NULL},