summaryrefslogtreecommitdiffstats
path: root/doc/guide/wsgi.py
diff options
context:
space:
mode:
authorAlexander Bokovoy <abokovoy@redhat.com>2011-11-22 15:39:23 +0200
committerAlexander Bokovoy <abokovoy@redhat.com>2011-11-22 15:52:02 +0200
commitd09389ab6fe203ce93d1a68986ff93c8ad75a480 (patch)
treea9d7e4357eb7603c9394fa21b1190812354c819c /doc/guide/wsgi.py
parent17cc52a1541b8326e9a7b1146285fe9ff4171782 (diff)
downloadfreeipa-d09389ab6fe203ce93d1a68986ff93c8ad75a480.tar.gz
freeipa-d09389ab6fe203ce93d1a68986ff93c8ad75a480.tar.xz
freeipa-d09389ab6fe203ce93d1a68986ff93c8ad75a480.zip
Add "Extending FreeIPA" developer guide
"Extending FreeIPA" is a developer guide of FreeIPA core framework. Please make sure to improve the guide every time parts of the core framework are affected by your changes. This document ideally should correspond to the current state of the framework. The Guide is written using Emacs Org Mode but can be edited with any plain text editing tool. Emacs is only required to convert it to distribution formats like HTML and TXT. See guide/Makefile for building the guide and README for details of the build environment.
Diffstat (limited to 'doc/guide/wsgi.py')
-rw-r--r--doc/guide/wsgi.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/guide/wsgi.py b/doc/guide/wsgi.py
new file mode 100644
index 000000000..2c4a9aaaa
--- /dev/null
+++ b/doc/guide/wsgi.py
@@ -0,0 +1,26 @@
+from ipalib import api
+from ipalib.config import Env
+from ipalib.constants import DEFAULT_CONFIG
+
+# Determine what debug level is configured. We can only do this
+# by reading in the configuration file(s). The server always reads
+# default.conf and will also read in `context'.conf.
+env = Env()
+env._bootstrap(context='server', log=None)
+env._finalize_core(**dict(DEFAULT_CONFIG))
+
+# Initialize the API with the proper debug level
+api.bootstrap(context='server', debug=env.debug, log=None) (ref:wsgi-app-bootstrap)
+try:
+ api.finalize() (ref:wsgi-app-finalize)
+except StandardError, e:
+ api.log.error('Failed to start IPA: %s' % e)
+else:
+ api.log.info('*** PROCESS START ***')
+
+ # This is the WSGI callable:
+ def application(environ, start_response): (ref:wsgi-app-start)
+ if not environ['wsgi.multithread']:
+ return api.Backend.session(environ, start_response)
+ else:
+ api.log.error("IPA does not work with the threaded MPM, use the pre-fork MPM") (ref:wsgi-app-end)