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
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to