I implemented the 4/7 WEP for refactoring the methods of Page. I found it
pretty easy to upgrade my projects to the new API. The WebKit example and
admin pages were especially easy, since they already invoked writeBody().
The biggest change is to rename your writeBody() methods to writeContent().
Also, if you override the old writeHeader(), you'll have to rework that a
But there is also a Page051 you can switch your inheritance to if you want.
Next, I'll work on release notes describing the change.
Here are the code and doc strings for your reference:
Writes all the HTML for the page.
Subclasses may override this method (which is invoked by
respondToGet() and respondToPost()) or more commonly its
constituent methods, writeDocType(), writeHead() and
Invoked by writeHTML() to write the <!DOCTYPE ...> tag. This
implementation specifies HTML 4.01 Transitional. Subclasses may
override to specify something else.
You can find out more about doc types by searching for DOCTYPE
on the web, or visiting:
self.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Writes the <head> portion of the page by writing the
<head>...</head> tags and invoking writeHeadParts() in between.
wr = self.writeln
Writes the parts inside the <head>...</head> tags. Invokes
writeTitle() and writeStyleSheet(). Subclasses can override this
to add additional items and should invoke super.
Writes the <title> portion of the page. Uses title().
self.writeln('\t<title>%s</title>' % self.title())
Writes the style sheet for the page, however, this default
implementation does nothing. Subclasses should override if
necessary. A typical implementation is:
self.writeln('\t<link rel=stylesheet href=StyleSheet.css
Writes the <body> portion of the page by writing the
<body>...</body> (making use of self.htBodyArgs()) and invoking
self.writeBodyParts() in between.
wr = self.writeln
wr('<body %s>' % self.htBodyArgs())
Invokes writeContent(). Subclasses should only override this
method to provide additional page parts such as a header,
sidebar and footer, that a subclass doesn't normally have to
worry about writing.
For writing page-specific content, subclasses should override
See SidebarPage for an example override of this method.
Invoked by writeBody().
Writes the unique, central content for the page.
Subclasses should override this method (not invoking super) to
write their unique page content.
Invoked by writeBodyParts().
self.writeln('<p> This page has not yet customized its content. </p>')