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@60 | 15 | Currently, BaseHTTPRequestHandler (via BaseHTTPServer in the standard library),
|
paulb@60 | 16 | mod_python, Twisted and Webware are supported. Each framework has its own set of
|
paulb@60 | 17 | strengths and weaknesses, but the idea is that deployment concerns can be
|
paulb@60 | 18 | considered separately from the implementation of application functionality.
|
paulb@63 | 19 | Consult the NOTES.txt files in each framework's subdirectory of the docs
|
paulb@63 | 20 | directory for some notes on how applications may be run in each environment.
|
paulb@60 | 21 |
|
paulb@68 | 22 | Tested Frameworks
|
paulb@68 | 23 | -----------------
|
paulb@68 | 24 |
|
paulb@68 | 25 | BaseHTTPRequestHandler Python 2.2.2
|
paulb@102 | 26 | mod_python 3.0.3 (3.1.3 for cookie support)
|
paulb@68 | 27 | Twisted 1.0.5
|
paulb@68 | 28 | Webware 0.8.1, CVS (2004-02-06)
|
paulb@68 | 29 |
|
paulb@68 | 30 | Future Work
|
paulb@68 | 31 | -----------
|
paulb@68 | 32 |
|
paulb@60 | 33 | Things to consider for future releases: higher-level authentication support,
|
paulb@68 | 34 | cookie handling, redirects, session interfaces, and much better documentation.
|
paulb@68 | 35 |
|
paulb@88 | 36 | Field access needs testing, especially for anything using the cgi.FieldStorage
|
paulb@102 | 37 | class - Webware and Twisted certainly need reviewing. The acquisition of
|
paulb@102 | 38 | fields from specific sources should be made more strict - some frameworks (eg.
|
paulb@102 | 39 | mod_python) provide path fields in the body fields dictionary.
|
paulb@102 | 40 |
|
paulb@102 | 41 | Cookie objects need defining strictly, especially since the standard library
|
paulb@102 | 42 | Cookie object behaves differently to mod_python (and possibly Webware) Cookie
|
paulb@103 | 43 | objects. Moreover, the set_cookie_value method needs to provide access to the
|
paulb@103 | 44 | usual cookie parameters as supported by the frameworks.
|
paulb@90 | 45 |
|
paulb@90 | 46 | Java Servlet API Notes
|
paulb@90 | 47 | ----------------------
|
paulb@90 | 48 |
|
paulb@94 | 49 | Using JythonServlet:
|
paulb@90 | 50 |
|
paulb@94 | 51 | mkdir SimpleApp
|
paulb@94 | 52 | mkdir SimpleApp/WEB-INF
|
paulb@94 | 53 | mkdir SimpleApp/WEB-INF/classes
|
paulb@94 | 54 | mkdir SimpleApp/WEB-INF/jython
|
paulb@94 | 55 | mkdir SimpleApp/WEB-INF/lib
|
paulb@94 | 56 | cp ${JYTHON_HOME}/jython.jar SimpleApp/WEB-INF/lib
|
paulb@94 | 57 | cp -R ${WEBSTACK_HOME}/WebStack SimpleApp/WEB-INF/jython
|
paulb@94 | 58 | cp -R ${WEBSTACK_HOME}/examples/Common/Simple SimpleApp/WEB-INF/jython
|
paulb@94 | 59 | cp ${WEBSTACK_HOME}/examples/JavaServlet/SimpleApp.py SimpleApp
|
paulb@94 | 60 | cp ${WEBSTACK_HOME}/examples/JavaServlet/web.xml SimpleApp/WEB-INF
|
paulb@94 | 61 | mv SimpleApp ${CATALINA_HOME}/webapps
|
paulb@90 | 62 |
|
paulb@94 | 63 | Unfortunately, PyServlet doesn't manage to find various modules in packages:
|
paulb@90 | 64 |
|
paulb@94 | 65 | javax.servlet.ServletException: Could not create Jython servletTraceback (innermost last):
|
paulb@94 | 66 | File "/data/home/paulb/Software/Java/jakarta-tomcat-4.1.27/webapps/SimpleApp/SimpleApp.py", line 3, in ?
|
paulb@94 | 67 | ImportError: cannot import name JavaServlet
|
paulb@94 | 68 |
|
paulb@94 | 69 | The same modules can be imported in interactive Jython.
|