[Grok-dev] Problem with applySkin (Grok 0.12)

Sebastian Ware sebastian at urbantalk.se
Fri Jul 11 07:23:40 EDT 2008


The skins are working fine with "++skin++mobile" but I can't get the  
applySkin to work (I am using grok 0.12). Basically nothing happens,  
no error, nothing. It just keeps on using the default skin. And I have  
checked that the applySkin method is actually called.

   #############################
  ###      Mobile skin      ###
#############################

from zope.publisher.interfaces.browser import IDefaultBrowserLayer
class MobileLayer(IDefaultBrowserLayer):
     pass

class MobileSkin(grok.Skin):
     grok.name('mobile')
     grok.layer(MobileLayer)

class MobileTemplate(grok.View):
     grok.layer(MobileLayer)
     grok.context(Interface)

from zope.app.publication.interfaces import IBeforeTraverseEvent
from zope.publisher.browser import applySkin
@grok.subscribe(grok.View, IBeforeTraverseEvent)
def handle(obj, event):
     if event.request.get('HTTP_USER_AGENT').find('Safari') > -1:
         applySkin(event.request, MobileLayer)



Mvh Sebastian




More information about the Grok-dev mailing list