Zope 3 Tutorial (Part 2)

Zope 3 has a concept of View Components, which could be any sort of
view on an object - HTML, FTP, XMLRPC, or even native widgets for an
operating system. Views and controllers specific to an HTML interface
are typically thought of as "browser" views. There's a browser ZCML
namespace, where most web views are configured, and it seems to be a
common practice to group code for web browsers in a python package or
module called browser to connote the type of view that it is. XMLRPC
views are typically bundled in a module or package called xmlrpc,
etc. There is no enforcement of these names.

So what we're interested in now is making a custom look for a web
browser. Zope 3's browser UI system uses a concept of skins, which are
made up of layers. Browser views are assigned to layers. When a view
needs to be looked up, the Zope 3 framework goes through the layers
defined for the current skin and looks up the requested view until it
finds it. This is similar, I suppose, to how a CSS class is looked
up. The HTML code may say to use class 'highlight', and the style
sheets are gone through in order until 'highlight' is
found. Replacement style sheets may be used (such as print or
presentation) that display the 'highlight' class differently.

To make the collector's skin, I made a new directory in the collector
package named browser, and made it into a Python package by adding an
empty __init__.py. I then made a sub-package of browser called skin,
and added an empty __init__.py there as well.

Once there, I made a new file called view_macros.pt. Using the
'Developing New Skins' chapter of the Zope 3 Developers Book for
guidance, I created the following template (Note that this is done
using Zope Page Templates):

As you can see, it pretty much maps to the list of items above. A
layer is made, named todo, and a skin of the same name is made with
the layers todo, rotterdam, and default. When the todo skin is used,
views will be looked up in that order, starting from the beginning of
the chain. After that, we define the CSS file as a resource to be used
in the todo layer. And then we define a page for the template, also in
the todo layer. Note that there's a for="*" in the page
declaration. That means the page is a browser view that can be used
for any object in the system. We want this because this page defines
the basic ZPT METAL macros that all other pages/templates will use.