ModjyIndex » History » Version 1
Alan Kennedy, 2009-03-15 09:01 PM
1 | 1 | Alan Kennedy | h1. A WSGI server for jython |
---|---|---|---|
2 | 1 | Alan Kennedy | |
3 | 1 | Alan Kennedy | h2(#intro). Introduction to modjy |
4 | 1 | Alan Kennedy | |
5 | 1 | Alan Kennedy | |
6 | 1 | Alan Kennedy | Python *Web Server Gateway Interface*, as specified in "PEP-333":http://www.python.org/dev/peps/pep-0333/, is a ??simple and universal interface between web servers and [python] web applications or frameworks??. |
7 | 1 | Alan Kennedy | |
8 | 1 | Alan Kennedy | Modjy is an implementation of a WSGI compliant gateway/server for jython, built on "Java/J2EE servlets":http://java.sun.com/products/servlet/. Which means that |
9 | 1 | Alan Kennedy | |
10 | 1 | Alan Kennedy | |
11 | 1 | Alan Kennedy | # Jython WSGI applications run inside a Java/J2EE servlet container, e.g. "Apache Tomcat":http://tomcat.apache.org/ |
12 | 1 | Alan Kennedy | # Incoming requests are handled by the servlet container |
13 | 1 | Alan Kennedy | # The container is configured to route requests to the modjy servlet |
14 | 1 | Alan Kennedy | # The modjy servlet creates an embedded jython interpreter inside the servlet container, and loads a configured jython web application, e.g. "Django":http://www.djangoproject.com/, ??the web framework for perfectionists with deadlines??. |
15 | 1 | Alan Kennedy | # The modjy servlet delegates the requests to the configured WSGI application or framework. |
16 | 1 | Alan Kennedy | # The WSGI response is routed back to the client through the servlet container. |
17 | 1 | Alan Kennedy | |
18 | 1 | Alan Kennedy | |
19 | 1 | Alan Kennedy | For further information about WSGI, see "wsgi.org":http://wsgi.org. For a detailed specification of WSGI see "PEP-333: Python Web Server Gateway Interface, version 1.0":http://www.python.org/dev/peps/pep-0333/. |
20 | 1 | Alan Kennedy | |
21 | 1 | Alan Kennedy | |
22 | 1 | Alan Kennedy | |
23 | 1 | Alan Kennedy | |
24 | 1 | Alan Kennedy | h2(#toc). How to use modjy |
25 | 1 | Alan Kennedy | |
26 | 1 | Alan Kennedy | |
27 | 1 | Alan Kennedy | |
28 | 1 | Alan Kennedy | # See the [[ModjyDownload|download]] page to find out how to get hold of modjy. |
29 | 1 | Alan Kennedy | # See the [[ModjyInstall|install]] page to read about installing modjy |
30 | 1 | Alan Kennedy | # See the [[ModjyConfiguration|configuration]] page to read about the various configuration options available to you for configuring modjy |
31 | 1 | Alan Kennedy | # See the [[ModjyLocateCallables|loading applications]] page to find out about the different mechanisms that modjy can use to locate and load WSGI callable objects |
32 | 1 | Alan Kennedy | # See the [[ModjyWSGI|WSGI]] page for a discussion of how modjy complies with the WSGI standard. |
33 | 1 | Alan Kennedy | |
34 | 1 | Alan Kennedy | |
35 | 1 | Alan Kennedy | |
36 | 1 | Alan Kennedy | h2(#license). License: Apache License Version 2.0 |
37 | 1 | Alan Kennedy | |
38 | 1 | Alan Kennedy | |
39 | 1 | Alan Kennedy | Modjy is released under the "Apache License Version 2.0":http://www.apache.org/licenses/LICENSE-2.0.html |
40 | 1 | Alan Kennedy | |
41 | 1 | Alan Kennedy | The full text of the licence, including all terms and conditions, is included in the "Download":download.html. |
42 | 1 | Alan Kennedy | |
43 | 1 | Alan Kennedy | |
44 | 1 | Alan Kennedy | |
45 | 1 | Alan Kennedy | h2(#structural_overview). A structural overview of modjy |
46 | 1 | Alan Kennedy | |
47 | 1 | Alan Kennedy | |
48 | 1 | Alan Kennedy | |
49 | 1 | Alan Kennedy | h3. Architecture |
50 | 1 | Alan Kennedy | |
51 | 1 | Alan Kennedy | |
52 | 1 | Alan Kennedy | |
53 | 1 | Alan Kennedy | The architecture of modjy is very simple, from a J2EE point of view. It consists of a single java servlet class, which is a thin wrapper around the required jython functionality. Since the java servlet is multithreaded, only one instance of it will ever run in a given container (unless configured otherwise). This java servlet also initializes the jython runtime, setting some necessary parameters beforehand. |
54 | 1 | Alan Kennedy | |
55 | 1 | Alan Kennedy | |
56 | 1 | Alan Kennedy | |
57 | 1 | Alan Kennedy | The java servlet then creates a single instance of the jython-implemented *modjy_servlet* class, to which all incoming HTTP requests are delegated. Depending on configuration, modjy_servlet creates 1 or more instances of the jython WSGI application object, as described in "How modjy locates application callable objects":ModjyLocateCallables. It then creates WSGI environment and start_response_callable objects, and invokes the application. |
58 | 1 | Alan Kennedy | |
59 | 1 | Alan Kennedy | |
60 | 1 | Alan Kennedy | |
61 | 1 | Alan Kennedy | More details on how to configure modjy to use single vs. multi threading, etc, see the "Configuration reference":params.html. |
62 | 1 | Alan Kennedy | |
63 | 1 | Alan Kennedy | |
64 | 1 | Alan Kennedy | |
65 | 1 | Alan Kennedy | h3. Code structure |
66 | 1 | Alan Kennedy | |
67 | 1 | Alan Kennedy | |
68 | 1 | Alan Kennedy | |
69 | 1 | Alan Kennedy | The principal jython class for implementation of modjy is the *modjy_servlet* class. This class uses "mixins":http://en.wikipedia.org/wiki/Mixin to "factor out code by functionality":http://www.linuxjournal.com/article/4540, so that the structure can be more easily evolved, components replaced, etc. |
70 | 1 | Alan Kennedy | |
71 | 1 | Alan Kennedy | |
72 | 1 | Alan Kennedy | |
73 | 1 | Alan Kennedy | Modjy has been updated to work on jython 2.5 and jython 2.2, and will no longer run on jython 2.1. |