[Zope3-Users] Default Skins for certain sites - how?

Rupert Redington rupert at neontribe.co.uk
Thu Jun 21 06:22:18 EDT 2007


Hi Hermann,

I do this by registering a subscriber for
zope.app.publication.interfaces.IBeforeTraverseEvent:

<subscriber
      handler=".handlers.skinTraverseSubscriber"
      for="zope.app.publication.interfaces.IBeforeTraverseEvent" />

the handler sets the skin:
(note that my site objects have a site_skin attribute which allows me to
switch skins.)

def skinTraverseSubscriber(event):
    """ Sets the skin during traversal"""
    if (IMySite.providedBy(event.object) and
        IBrowserRequest.providedBy(event.request)):
        skin = zope.component.getUtility(IBrowserSkinType,
event.object.site_skin)
        if not '++skin++' in event.request.URL[0]:
            applySkin(event.request, skin)


I'm pretty sure that one shouldn't have to check the type of the object
that's being traversed. I believe that you should be able to add another
interface to the 'for' attribute of the subscriber zcml - but that never
worked for me.

I'd be interested in hearing other/more efficient ways of doing this though.

Rupert


More information about the Zope3-users mailing list