paulb@68 | 1 | Introduction
|
paulb@68 | 2 | ------------
|
paulb@68 | 3 |
|
paulb@60 | 4 | WebStack is a package which provides a common API for Python Web applications,
|
paulb@60 | 5 | regardless of the underlying server or framework environment. It should be
|
paulb@60 | 6 | possible with WebStack to design and implement an application and to choose a
|
paulb@60 | 7 | deployment environment, without having to go back and rewrite large parts of
|
paulb@60 | 8 | that application to work in the chosen environment or in other environments
|
paulb@60 | 9 | (should the deployment requirements change after the application has been
|
paulb@60 | 10 | written).
|
paulb@60 | 11 |
|
paulb@68 | 12 | Framework Support
|
paulb@68 | 13 | -----------------
|
paulb@68 | 14 |
|
paulb@120 | 15 | Currently, BaseHTTPRequestHandler (via BaseHTTPServer in the standard
|
paulb@120 | 16 | library), CGI, mod_python, Twisted and Webware are supported. Each framework
|
paulb@120 | 17 | has its own set of strengths and weaknesses, but the idea is that deployment
|
paulb@120 | 18 | concerns can be considered separately from the implementation of application
|
paulb@120 | 19 | functionality. Consult the NOTES.txt files in each framework's subdirectory
|
paulb@120 | 20 | of the docs directory for some notes on how applications may be run in each
|
paulb@120 | 21 | environment.
|
paulb@60 | 22 |
|
paulb@68 | 23 | Tested Frameworks
|
paulb@68 | 24 | -----------------
|
paulb@68 | 25 |
|
paulb@68 | 26 | BaseHTTPRequestHandler Python 2.2.2
|
paulb@120 | 27 | CGI Apache 2.0.44
|
paulb@102 | 28 | mod_python 3.0.3 (3.1.3 for cookie support)
|
paulb@68 | 29 | Twisted 1.0.5
|
paulb@68 | 30 | Webware 0.8.1, CVS (2004-02-06)
|
paulb@68 | 31 |
|
paulb@120 | 32 | Changes Since WebStack 0.2
|
paulb@120 | 33 | --------------------------
|
paulb@120 | 34 |
|
paulb@120 | 35 | Added better header support for Webware (suggested by Ian Bicking).
|
paulb@120 | 36 | Introduced CGI and Java Servlet support (the latter is currently
|
paulb@120 | 37 | broken/unfinished).
|
paulb@120 | 38 | Introduced support for cookies.
|
paulb@120 | 39 |
|
paulb@68 | 40 | Future Work
|
paulb@68 | 41 | -----------
|
paulb@68 | 42 |
|
paulb@60 | 43 | Things to consider for future releases: higher-level authentication support,
|
paulb@120 | 44 | improved cookie handling, redirects, session interfaces, and much better
|
paulb@120 | 45 | documentation.
|
paulb@68 | 46 |
|
paulb@88 | 47 | Field access needs testing, especially for anything using the cgi.FieldStorage
|
paulb@102 | 48 | class - Webware and Twisted certainly need reviewing. The acquisition of
|
paulb@102 | 49 | fields from specific sources should be made more strict - some frameworks (eg.
|
paulb@102 | 50 | mod_python) provide path fields in the body fields dictionary.
|
paulb@102 | 51 |
|
paulb@102 | 52 | Cookie objects need defining strictly, especially since the standard library
|
paulb@102 | 53 | Cookie object behaves differently to mod_python (and possibly Webware) Cookie
|
paulb@103 | 54 | objects. Moreover, the set_cookie_value method needs to provide access to the
|
paulb@103 | 55 | usual cookie parameters as supported by the frameworks.
|
paulb@90 | 56 |
|
paulb@90 | 57 | Java Servlet API Notes
|
paulb@90 | 58 | ----------------------
|
paulb@90 | 59 |
|
paulb@94 | 60 | Using JythonServlet:
|
paulb@90 | 61 |
|
paulb@94 | 62 | mkdir SimpleApp
|
paulb@94 | 63 | mkdir SimpleApp/WEB-INF
|
paulb@94 | 64 | mkdir SimpleApp/WEB-INF/classes
|
paulb@94 | 65 | mkdir SimpleApp/WEB-INF/jython
|
paulb@94 | 66 | mkdir SimpleApp/WEB-INF/lib
|
paulb@94 | 67 | cp ${JYTHON_HOME}/jython.jar SimpleApp/WEB-INF/lib
|
paulb@94 | 68 | cp -R ${WEBSTACK_HOME}/WebStack SimpleApp/WEB-INF/jython
|
paulb@94 | 69 | cp -R ${WEBSTACK_HOME}/examples/Common/Simple SimpleApp/WEB-INF/jython
|
paulb@94 | 70 | cp ${WEBSTACK_HOME}/examples/JavaServlet/SimpleApp.py SimpleApp
|
paulb@94 | 71 | cp ${WEBSTACK_HOME}/examples/JavaServlet/web.xml SimpleApp/WEB-INF
|
paulb@94 | 72 | mv SimpleApp ${CATALINA_HOME}/webapps
|
paulb@90 | 73 |
|
paulb@94 | 74 | Unfortunately, PyServlet doesn't manage to find various modules in packages:
|
paulb@90 | 75 |
|
paulb@94 | 76 | javax.servlet.ServletException: Could not create Jython servletTraceback (innermost last):
|
paulb@94 | 77 | File "/data/home/paulb/Software/Java/jakarta-tomcat-4.1.27/webapps/SimpleApp/SimpleApp.py", line 3, in ?
|
paulb@94 | 78 | ImportError: cannot import name JavaServlet
|
paulb@94 | 79 |
|
paulb@94 | 80 | The same modules can be imported in interactive Jython.
|