1 Introduction
2 ------------
3
4 WebStack is a package which provides a common API for Python Web
5 applications, regardless of the underlying server or framework environment.
6 It should be possible with WebStack to design and implement an application,
7 to choose a deployment environment, and then to be able to deploy the
8 application in a different environment later on without having to go back
9 and rewrite substantial parts of the application.
10
11 Quick Start
12 -----------
13
14 Try running the demo:
15
16 python tools/demo.py
17
18 An introductory guide to creating applications can be found in the docs
19 directory - see docs/index.html for the start page.
20
21 Contact, Copyright and Licence Information
22 ------------------------------------------
23
24 The current Web page for WebStack at the time of release is:
25
26 http://www.boddie.org.uk/python/WebStack.html
27
28 Copyright and licence information can be found in the docs directory - see
29 docs/COPYING.txt, docs/LICENCE.txt and docs/LICENCE-PyServlet.txt for more
30 information.
31
32 Framework Support
33 -----------------
34
35 See the docs/supported-frameworks.html document for more information.
36
37 Dependencies
38 ------------
39
40 WebStack has the following basic dependencies:
41
42 Packages Release Information
43 -------- -------------------
44
45 libxml2dom 0.4.3 (for OpenID support)
46 libxml2 and libxslt Some combinations may not be reliable!
47 Tested with libxml2 2.6.17 and libxslt 1.1.12
48 Tested with libxml2 2.6.27 and libxslt 1.1.20
49 libxslt 1.1.17 should be avoided
50
51 If the OpenID support is not used, the above packages need not be installed.
52
53 New in WebStack 1.3 (Changes since WebStack 1.2.7)
54 --------------------------------------------------
55
56 * Changed the default_charset on WebStack.Generic.Transaction to UTF-8,
57 introducing a safe_default_charset attribute which employs ISO-8859-1, and
58 removing the default encoding on various resources, making them rely on
59 the default_charset property instead.
60 WARNING: These changes could upset some applications. The EncodingSelector
61 should be used to override the default_charset setting if appropriate.
62 * Added an encode_url_without_query to Transaction for use with combined
63 protocol, address and path values.
64 * Added a StringResource to WebStack.Resources.Static, serving strings as
65 responses.
66 * Added Last-Modified headers to DirectoryResource and FileResource
67 responses.
68 * Added experimental OpenID support; improved the authentication resources
69 and mechanisms.
70 * Added a StoreSelector to WebStack.Resources.Selectors in order to provide
71 a convenient mechanism for database-related applications.
72 * Changed LoginRedirectResource to use class attributes for various optional
73 parameters, rather than having these supplied to the initialiser.
74 WARNING: These changes could affect some applications.
75 * Added a SiteLoginRedirectResource for site-specific login redirection to
76 WebStack.Resources.LoginRedirect.
77 * Added AuthInfoSelector for the retrieval of authentication details and
78 ConditionalAuthSelector for conditional authentication to
79 WebStack.Resources.Selectors.
80
81 New in WebStack 1.2.7 (Changes since WebStack 1.2.6)
82 ----------------------------------------------------
83
84 * Fixed the MessageBodyStream class, adding an optional parameter to the
85 readline method which seems to be necessary when handling multipart
86 requests.
87 * Introduced stream usage for file uploads where possible, in order to
88 reduce memory usage (suggested by Kevin Glynn), adding a stream attribute
89 to the FileContent class and making the content attribute a property.
90 * Removed error handling in the examples in order to make troubleshooting
91 easier.
92 * Fixed header issues by introducing a special HeaderDict class which
93 enforces the case-insensitivity expected of header dictionaries.
94
95 New in WebStack 1.2.6 (Changes since WebStack 1.2.5)
96 ----------------------------------------------------
97
98 * Added a jython-webstack package for Ubuntu Feisty (7.04).
99 * Improved support for Jython on Ubuntu Feisty (7.04), adding python.path
100 and python.cachedir settings which respectively avoid issues with missing
101 libraries (due to the separation of libraries in the Ubuntu package) and
102 with failed imports (due to a read-only class cache directory).
103 * Improved the webstack_java_build.py script and added a deployment
104 descriptor for JSP to accompany the new Java Servlet-specific JSPTest
105 example.
106 * Added a special Java Servlet-specific get_servlet method to support the
107 JSPTest example. It is envisaged that a more general method could be made
108 available for all frameworks in order to support access to underlying
109 request dispatchers and other framework facilities.
110 * Added more Jython-related documentation as suggested by Kevin Glynn.
111 * Added missing request headers for CGI/WSGI environment variables.
112 * Fixed Webware support to work with Webware 0.9.4.
113 * Fixed/improved Zope path value retrieval.
114 * Added support for wsgiref, changing the WSGI deploy function for CGI-based
115 applications to deploy_as_cgi and adding a deploy_with_wsgiref function.
116
117 New in WebStack 1.2.5 (Changes since WebStack 1.2.4)
118 ----------------------------------------------------
119
120 * Fixed mod_python status codes using a solution proposed by John Krukoff.
121 * Fixed a Twisted deprecation warning when accessing port numbers, thanks to
122 John Krukoff.
123 * Added Ubuntu Feisty (7.04) package support.
124 * Tidied up the documentation HTML.
125
126 New in WebStack 1.2.4 (Changes since WebStack 1.2.3)
127 ----------------------------------------------------
128
129 * Made a SessionDirectoryRepository which uses directories for data produced
130 by the shelve module, rather than attempting to manipulate files produced
131 by the shelve module, since the details of such files may differ between
132 environments: a situation noticed by John Krukoff in an environment
133 without the bsddb module installed.
134
135 New in WebStack 1.2.3 (Changes since WebStack 1.2.2)
136 ----------------------------------------------------
137
138 * Fixed inadvertent OpenSSL dependency, noticed by John Krukoff.
139
140 New in WebStack 1.2.2 (Changes since WebStack 1.2.1)
141 ----------------------------------------------------
142
143 * Added an EncodingSelector class for the setting of default encodings on
144 transactions.
145 * Added some documentation about path processing strategies.
146 * Added a secure variant of the BaseHTTPServer provided in the adapter for
147 BaseHTTPRequestHandler.
148
149 New in WebStack 1.2.1 (Changes since WebStack 1.2)
150 --------------------------------------------------
151
152 * Fixed mod_python get_content_type method.
153 * Fixed LoginResource form field processing; changed the field type to
154 password.
155 * Exposed LoginResource and LoginRedirectResource page contents as
156 attributes.
157 * Added documentation about extending LoginRedirectResource and using
158 PathSelector to remember an application's root path.
159 * Changed handle_errors to 1 throughout the examples.
160
161 New in WebStack 1.2 (Changes since WebStack 1.1.2)
162 --------------------------------------------------
163
164 * Added support for Django.
165 * Fixed documentation about the representation of file upload fields.
166 * Changed mod_python, Java Servlet and Webware (> 0.8.1) deployment to use a
167 deploy function instead of more complicated configuration mechanisms.
168 * Improved mod_python deployment documentation and tools so that cleaner
169 application paths/URLs can now be used.
170 * Moved user and path_info default definitions into WebStack.Generic as
171 class attributes.
172 * Fixed encoding usage issues with path fields when using get_fields in a
173 Zope environment.
174 * Added a FileResource class to WebStack.Resources.Static.
175 * Made DirectoryRepository convert filenames to Unicode in all cases.
176 * Renamed the Apache and Java Servlet tools, making them scripts which are
177 installed by setup.py.
178 * Fixed CGI content charsets and languages support.
179 * Fixed CGI cookie output.
180 * Added URL overriding in the LoginRedirectResource.
181 * Exposed a get_target function from WebStack.Resources.Login in order to
182 better support alternative login resources.
183 * Added improved error reporting for BaseHTTPRequestHandler, CGI, Django and
184 WSGI.
185 * Added a traverse_path method to the Transaction class.
186 * Made a path_encoding alias for urlencoding in the initialisation of
187 WebStack.Resources.ResourceMap objects.
188 * Added a Selectors module to WebStack.Resources in order to support common
189 resource selection patterns.
190
191 New in WebStack 1.1.2 (Changes since WebStack 1.1.1)
192 ----------------------------------------------------
193
194 * Fixed missing import in WebStack.Repositories.Directory.
195
196 New in WebStack 1.1.1 (Changes since WebStack 1.1)
197 --------------------------------------------------
198
199 * Fixed update_path to handle the root path properly.
200
201 New in WebStack 1.1 (Changes since WebStack 1.0)
202 ------------------------------------------------
203
204 * Added a Repositories package to provide session-like support for
205 different kinds of storage.
206 * Added an explicit filesystem encoding to the Calendar example and adopted
207 the DirectoryRepository from the Repositories package.
208 * Added get_path_without_info, update_path and redirect methods to the
209 Transaction class.
210 * Added get_attributes (attribute support) to the Transaction class.
211 * Added a values method to Helpers.Session.Wrapper.
212 * Fixed get_processed_virtual_path_info (to match from right to left).
213 * Improved/fixed exception handling in the adapters so that transactions are
214 committed as the final act of an adapter experiencing an unhandled
215 exception. This should result in session stores being closed properly.
216 * Changed the Helpers.Session.SessionStore to use DirectoryRepository.
217 * Made the "not found" behaviour of DirectoryResource more configurable.
218 * Added documentation for MapResource and DirectoryResource.
219 * Fixed the distribution names in the Ubuntu changelog.
220
221 New in WebStack 1.0 (Changes since WebStack 0.10)
222 -------------------------------------------------
223
224 * Changed the behaviour of get_path, get_path_without_query, get_path_info,
225 get_virtual_path_info, get_processed_virtual_path_info and
226 get_fields_from_path to return Unicode data decoded using the optional
227 encoding parameter or a common default encoding.
228 * Fixed file upload values so that FileContent objects are returned for such
229 fields in get_fields_from_body and get_fields.
230 (Warning! Except for Twisted!)
231 * Fixed the JavaServlet support so that streams and file content are
232 obtained as "almost" plain strings.
233 * Updated/fixed LoginResource and LoginRedirectResource to use the updated
234 path API and to handle special characters properly.
235 * Added convenience methods to Transaction for the decoding and encoding of
236 path values (to and from Unicode objects) - see the decode_path and
237 encode_path methods.
238 * Added the notion of processed virtual path info - the part of the original
239 path info not represented in the current virtual path info.
240 * Added "pass through" behaviour to ResourceMap.MapResource (prompted by a
241 patch from Scott Robinson).
242 * Fixed ResourceMap.MapResource to handle non-existent resources properly
243 (where the virtual path info is only one component in length).
244 * Added Debian package support.
245 * Added automatic session directory creation for the WebStack sessions
246 implementation.
247 * Added support for the repeated retrieval of sessions from the same
248 WebStack session store, avoiding deadlocks.
249 * Fixed the calendar example, making it perform a proper function.
250 * Made the BaseHTTPRequestHandler and Twisted SimpleWithLogin applications
251 include the Login application, since Konqueror (at least) does not share
252 cookies across different port numbers on the same host.
253 * Added the SimpleWithLogin and Login applications to the demonstration.
254 * Improved the documentation, adding information on request headers, and
255 describing file upload and session support limitations.
256 * Improved the AOLserver-related notes for CGI and Webware, adding a patch
257 for Webware in order to work around AOLserver issues.
258
259 New in WebStack 0.10 (Changes since WebStack 0.9)
260 -------------------------------------------------
261
262 * Changes to make the tools/demo.py script work on Windows (and other)
263 platforms (suggested by Jim Madsen).
264 * Fixed end of header newlines for CGI (suggested by Matt Harrison).
265 * Minor documentation fixes and improvements, adding information on
266 AOLserver in the CGI and Webware notes.
267 * Changed the mod_python server name method to use the server object rather
268 than the connection object.
269 * Added a parameter to the ResourceMap.MapResource class to permit automatic
270 redirects into resource hierarchies when no trailing "/" was given in the
271 URL; changed the updated virtual path info so that empty values may be set
272 (the guarantee that "/" will always appear no longer applies).
273 * Fixed virtual path info retrieval when the value is an empty string.
274
275 New in WebStack 0.9 (Changes since WebStack 0.8)
276 ------------------------------------------------
277
278 * Standardised error handling in the adapters so that tracebacks can be
279 suppressed and an internal server error condition raised.
280 * Added overriding of path info in transactions.
281 * Added a ResourceMap resource for dispatching to different resources
282 according to path components.
283 * Standardised deployment for some frameworks (see docs/deploying.html).
284 * Introductory documentation in XHTML format.
285 * Added server name and port methods to the transaction.
286 * Added a simple demonstration application, incorporating many of the
287 examples and launched under a single script.
288 * Fixed mod_python native sessions.
289 * Fixed Zope request stream access.
290 * WebStack is now licensed under the LGPL - see docs/COPYING.txt for
291 details.
292
293 New in WebStack 0.8 (Changes since WebStack 0.7)
294 ------------------------------------------------
295
296 * Added a standard exception, EndOfResponse, which can be used to
297 immediately stop the processing/production of a response; this is useful
298 when resources need to issue a redirect without unnecessary content being
299 generated, for example.
300 * Fixed path information for Zope.
301 * Added WSGI support.
302 * Verified Twisted 1.3.0 support with Python 2.3.3.
303
304 New in WebStack 0.7 (Changes since WebStack 0.6)
305 ------------------------------------------------
306
307 * Fixed path information semantics.
308 * Fixed file upload semantics.
309 * Fixed content type handling for Unicode output and for interpreting
310 request body fields/parameters (although some improvement remains).
311 * Added a method to discover the chosen response stream encoding.
312 * Fixed field/parameter retrieval so that path and body fields are distinct,
313 regardless of the framework employed.
314 * Added a method to get a combination of path and body fields (suggested by
315 Jacob Smullyan).
316 * Introduced Zope 2 support.
317 * Improved Jython/Java Servlet API support (although a special PyServlet
318 class must now be used, and certain libraries must be deployed with
319 applications).
320 * Introduced authentication/authorisation support for Jython/Java Servlet
321 API.
322 * Session support has been added (except for Webware 0.8.1).
323 * Alternative cookie support for mod_python has been added.
324 * Cookie support now supports encoded Unicode sequences for names and
325 values.
326
327 New in WebStack 0.6 (Changes since WebStack 0.5)
328 ------------------------------------------------
329
330 * Introduced Jython/Java Servlet API support.
331 * Minor fixes to example applications and to BaseHTTPRequestHandler.
332
333 New in WebStack 0.5 (Changes since WebStack 0.4)
334 ------------------------------------------------
335
336 * Changed request body fields/parameters so that they are now represented
337 using Unicode objects rather than plain strings.
338 * Introduced better support for Unicode in response streams.
339
340 New in WebStack 0.4 (Changes since WebStack 0.3)
341 ------------------------------------------------
342
343 * Added application definition of user identity, permitting alternative
344 authentication mechanisms.
345 * Improved BaseHTTPRequestHandler and mod_python reliability around fields
346 from request bodies.
347 * Provided stream and environment parameterisation in the CGI adapter.
348 * Added LoginRedirect and Login examples.
349 * Added get_path_without_query and fixed get_path behaviour.
350
351 New in WebStack 0.3 (Changes since WebStack 0.2)
352 ------------------------------------------------
353
354 * Added better header support for Webware (suggested by Ian Bicking).
355 * Introduced CGI and Java Servlet support (the latter is currently
356 broken/unfinished).
357 * Introduced support for cookies.
358
359 Future Work
360 -----------
361
362 (Essential)
363
364 Twisted 1.3.0 does not provide file upload metadata, and Twisted Web 0.5.0
365 also seems to be missing this functionality. It isn't obvious whether Twisted
366 Web2 will just copy its predecessors and provide a similarly limited API.
367 Perhaps the Twisted support needs to resemble the CGI support much more when
368 handling fields.
369
370 JythonServlet libraries need to be configured using sys.add_package when
371 these do not feature in the compiled-in list. Adding such configuration to
372 the handler may be most appropriate (since the web.xml file can be too
373 arcane), but this needs testing.
374
375 The algorithm employed in the WebStack.Helpers.Auth.get_token function
376 should be reviewed and improved for better security.
377
378 (Important)
379
380 Field access needs testing, especially for anything using the
381 cgi.FieldStorage class, and the way file uploads are exposed should be
382 reviewed (currently the meta-data is not exposed). The acquisition of fields
383 from specific sources should be tested with different request methods - some
384 frameworks provide path fields in the body fields dictionary, others (eg.
385 Zope) change the fields exposed depending on request method.
386
387 Interpretation of path field encodings needs to be verified. Currently,
388 stray path fields are handled (eg. in WebStack.Helpers.Request) as being
389 ISO-8859-1, but it might be the case that some such fields might be
390 submitted as UTF-8. The decode_path method on Transaction does do much of the
391 work that is likely to be required, however. Still, a good policy for decoding
392 path fields, reducing the number of times one might specify the encoding in
393 various method calls, may be important.
394
395 An interesting test of encodings is to introduce things like the following to
396 the path info and query string sections of the URL: %25F0?%E6=%F8&%25F0=%F8
397 This should produce the following decoded result: %F0?æ=ø&%F0=ø
398 (The above needs to be read in ISO-8859-1 or ISO-8859-15.)
399
400 Cookie objects need defining strictly, especially since the standard library
401 Cookie object behaves differently to mod_python (and possibly Webware)
402 Cookie objects. Moreover, the set_cookie_value method needs to provide
403 access to the usual cookie parameters as supported by the frameworks. The
404 standard library Cookie module has issues with Unicode cookie names (and
405 possibly values) - this is worked around, but it would be best to resolve
406 this comprehensively.
407
408 UTF-16 (and possibly other encodings) causes problems with HTML form data
409 sent in POST requests using the application/x-www-form-urlencoded content
410 type. This should be reviewed at a later date when proper standardisation
411 has taken place.
412
413 Session support, especially through WebStack.Helpers.Session, should be
414 reviewed and be made compatible with non-cookie mechanisms.
415
416 Locking in the session support and in DirectoryRepository should be improved.
417
418 HeaderValue objects should be employed more extensively. Thus, the header
419 access methods may need to change their behaviour slightly. The get_headers
420 method should potentially return a list for each item in the dictionary.
421
422 WSGI support could demand that a special "end of headers" method be
423 introduced into WebStack, thus making response output more efficient (and
424 probably also for other frameworks, too).
425
426 Investigate proper support for HEAD, OPTIONS and other request methods.
427
428 Consider packages for different operating systems (other than Debian).
429
430 Investigate cStringIO usage.
431
432 The location of deployed applications in the filesystem should be exposed to
433 those applications. (This is actually available in the __file__ module
434 variable.) A resource could be provided to record the "root" path and added to
435 a resource hierarchy or site map. Note that PathSelector records the "root"
436 path, although it is not automatically deployed.
437
438 (Completed/rejected)
439
440 Path information should be consistent across all frameworks, and the "path
441 info" value should be meaningful. (This should now be correct.)
442
443 Investigate the nicer functions in the cgi module, discarding the "magic"
444 stuff like FieldStorage. (These nicer functions are used by projects like
445 Twisted - as of 1.3.0 at least - and do not give the necessary information we
446 require.)
447
448 Release Procedures
449 ------------------
450
451 Update the WebStack/__init__.py __version__ attribute.
452 Change the version number and package filename/directory in the documentation.
453 Change code examples in the documentation if appropriate.
454 Update the release notes (see above).
455 Check the setup.py file and ensure that all package directories are mentioned.
456 Check the release information in the PKG-INFO file and in the package
457 changelog (and other files).
458 Tag, export.
459 Generate the PyServlet classes.
460 Generate the API documentation.
461 Remove generated .pyc files: rm `find . -name "*.pyc"`
462 Archive, upload.
463 Upload the introductory documentation.
464 Update PyPI, PythonInfo Wiki entries.
465
466 Generating the PyServlet Classes
467 --------------------------------
468
469 In order to generate the PyServlet classes, it is necessary to run the
470 supplied script:
471
472 ./tools/JavaServlet/compile.sh
473
474 This produces Java classes and a .jar file for use by WebStack applications
475 running on the Java platform.
476
477 Generating the API Documentation
478 --------------------------------
479
480 In order to prepare the API documentation, it is necessary to generate some
481 Web pages from the Python source code. For this, the epydoc application must
482 be available on your system. Then, inside the distribution directory, run the
483 apidocs.sh tool script as follows:
484
485 ./tools/apidocs.sh
486
487 Some warnings may be generated by the script, but the result should be a new
488 apidocs directory within the distribution directory.
489
490 Making Packages
491 ---------------
492
493 To make Debian-based packages:
494
495 1. Create new package directories under packages if necessary.
496 2. Make a symbolic link in the distribution's root directory to keep the
497 Debian tools happy. For example, one of the following:
498
499 ln -s packages/ubuntu-hoary/python2.4-webstack/debian/
500 ln -s packages/ubuntu-feisty/python-webstack/debian/
501 ln -s packages/ubuntu-feisty/jython-webstack/debian/
502
503 3. Run the package builder:
504
505 dpkg-buildpackage -rfakeroot
506
507 4. Locate and tidy up the packages in the parent directory of the
508 distribution's root directory.