[PEAK] FYI: peak.web refactoring in progress...

Phillip J. Eby pje at telecommunity.com
Thu Jun 3 11:57:55 EDT 2004


I'm going to try to keep it so that existing apps (such as the DDT web 
runner) will still work, with the following exceptions:

* The pageProtocol, pathProtocol, and errorProtocol machinery is going 
away, being replaced by direct usage of IWebPage, IWebTraversable, and 
IWebException respectively.  This means that you won't be able to define 
multiple web applications layered over the same domain objects and 
services, but I don't think anybody has used that feature yet, because it 
was so obscure as to *how*.  In the long run, this feature will come back 
via a different route: you'll simply write a different XML file to define a 
new application over the same components.

* The DOMlet interfaces and implementation may change significantly.

* The Zope request/response objects will be going away, so all capabilities 
based on them will have to go away too.  This means no cookie parsing or 
setting, unless you roll your own (or use another library).  It also means 
no query string or form variable processing, unless you roll your own or 
use another library (such as the 'cgi' module).  And last, but far from 
least, it means that arbitrary callables (such as functions and methods) 
can't be used as web pages, unless they use a fixed calling signature.  The 
CallableAsWebPage adapter will be changed to use this calling format:

     def someMethod(environ,input,errors):
         return status,headers,output_iterable

For example, in 'trivial_web', the current:

     def index_html(self):
         return "Hello world!"

would need to be rephrased as:

     def index_html(self, environ, input, errors):
         return "200", ["Content-type: text/plain"], ["Hello world!"]


Once the basic refactoring is complete, we can begin to replace some of the 
Zope request/response functionality, via functions that operate on 
environ+input, or that return header lines for use in the return 
value.  For example, if index_html wanted to set a cookie, it might do 
something like:

     def index_html(self, environ, input, errors):
         return "200", [
             "Content-type: text/plain",
             web.cookieHeader(someData)
         ], ["Hello world!"]


Please let me know if you have any questions or concerns.  And I'd 
especially like to know if any of my checkins breaks anything in your 
existing applications.  Thanks.




More information about the PEAK mailing list