[Framework-Team] plone.theme - one more package for Plone 3?
optilude at gmx.net
Mon May 21 21:17:06 UTC 2007
David, Florian and I were discussing the skinning story in Plone 3.
David was a bit frustrated trying to customize things like the portal
logo in a clean way. We made some headway, but discovered that it wasn't
very easy to make use of Zope 3 browser layers in Plone.
For those not familiar with them, browser layers are markers which are
applied to the request during traversal. You can register views,
viewlets etc for a particular layer marker, either to override a view
for a particular skin/theme, or to make sure a particular viewlet is
only shown in a particular skin/theme.
This will only show up if the IMyTheme skin/browser layer is applied.
The most obvious way for this to would be for IMyTheme to correspond to
a particular theme/skin as selected in portal_skins.
That's where plone.theme comes in. It provides an event handler
listening to IBeforeTraverseEvent, and will attempt to match a browser
layer marker to the current skin selection.
To use it, let's say you have "My Theme" in portal_skins. You could then
have a marker interface like:
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
"""Marker interface used in the tests
and in configure.zcml:
The trick here is that the name of the IBrowserSkinType utility matches
the name of the skin selection/theme in portal_skins.
The code is here:
It's pretty simple, and there are (doc)tests. It should be pretty low risk.
Now, nothing in Plone core uses this (though NuPlone could use it,
perhaps). I can release this to the Cheese Shop and things like
DIYPloneStyle can depend on it. However, it may be useful to integrators
and customisers if this is part of the Plone 3 distribution, and its
ZCML was loaded from Products/CMFPlone to avoid slugs or needing to
include it explicitly.
I can manage the release and add it to the lib bundle and ploneout, if
no-one objects to it going in at this (admittedly late) stage.
More information about the Framework-Team