summaryrefslogtreecommitdiffstats
path: root/source4/web_server
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-23 21:21:07 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-21 16:03:52 +0200
commit4bb17b60ef608b10284ccd2146c9344cc43b8637 (patch)
treecd3da3bfb410ecaac148fd69443a3993273b6ac9 /source4/web_server
parentef5a04485ae256f9b803da9173d6194ced82e358 (diff)
downloadsamba-4bb17b60ef608b10284ccd2146c9344cc43b8637.tar.gz
samba-4bb17b60ef608b10284ccd2146c9344cc43b8637.tar.xz
samba-4bb17b60ef608b10284ccd2146c9344cc43b8637.zip
Add initial work on WSGI support in the web server.
Diffstat (limited to 'source4/web_server')
-rw-r--r--source4/web_server/config.mk2
-rw-r--r--source4/web_server/wsgi.c69
2 files changed, 70 insertions, 1 deletions
diff --git a/source4/web_server/config.mk b/source4/web_server/config.mk
index 4094d6be07..810cc7f430 100644
--- a/source4/web_server/config.mk
+++ b/source4/web_server/config.mk
@@ -10,6 +10,6 @@ PRIVATE_DEPENDENCIES = ESP LIBTLS smbcalls process_model
# End SUBSYSTEM WEB
#######################
-WEB_OBJ_FILES = $(addprefix $(web_serversrcdir)/, web_server.o esp.o)
+WEB_OBJ_FILES = $(addprefix $(web_serversrcdir)/, web_server.o esp.o wsgi.o)
$(eval $(call proto_header_template,$(web_serversrcdir)/proto.h,$(WEB_OBJ_FILES:.o=.c)))
diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c
new file mode 100644
index 0000000000..50f8599869
--- /dev/null
+++ b/source4/web_server/wsgi.c
@@ -0,0 +1,69 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
+
+ Implementation of the WSGI interface described in PEP0333
+ (http://www.python.org/dev/peps/pep-0333)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include <Python.h>
+
+static PyObject *start_response(PyObject *args, PyObject *kwargs)
+{
+ PyObject *response_header, *exc_info;
+ char *status;
+ const char *kwnames[] = {
+ "status", "response_header", "exc_info", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *)"sOO:start_response", (char **)kwnames, &status, &response_header, &exc_info)) {
+ return NULL;
+ }
+
+ /* FIXME: response_header, exc_info */
+
+ /* FIXME: Wrap stdout */
+ return NULL;
+}
+
+static PyObject *create_environ(void)
+{
+ PyObject *env, *osmodule, *osenviron;
+
+ osmodule = PyImport_ImportModule("os");
+ if (osmodule == NULL)
+ return NULL;
+
+ osenviron = PyObject_CallMethod(osmodule, "environ", NULL);
+
+ env = PyDict_Copy(osenviron);
+
+ PyDict_SetItemString(env, "wsgi.input", NULL); /* FIXME */
+ PyDict_SetItemString(env, "wsgi.errors", NULL); /* FIXME */
+ PyDict_SetItemString(env, "wsgi.version", Py_BuildValue("(i,i)", 1, 0));
+ PyDict_SetItemString(env, "wsgi.multithread", Py_False);
+ PyDict_SetItemString(env, "wsgi.multiprocess", Py_True);
+ PyDict_SetItemString(env, "wsgi.run_once", Py_False);
+
+ /* FIXME:
+ PyDict_SetItemString(env, "wsgi.url_scheme", "http");
+ PyDict_SetItemString(env, "wsgi.url_scheme", "https");
+ */
+
+ return env;
+}