[Grok-dev] grok.layer branch

Kevin Smith kevin at mcweekly.com
Fri Apr 13 16:26:03 EDT 2007


My current project requires a separate public and admin skin. Originally 
Grok was going to be used for just the admin interface and the public 
interface was to be implemented using normal Zope3 views. Unfortunately 
Grok has ruined me for zcml and I can't go back.

The grok.layer directive works at both the class and module level and 
works with Zope3's existing skin/layer implementation.

 From the functional tests...

import grok
from zope.app.basicskin import IBasicSkin
from zope.app.rotterdam import rotterdam

grok.layer(IBasicSkin) #default module level skin

class Mammoth(grok.Model):

class CaveDrawings(grok.View):

cavedrawings = grok.PageTemplate("""\
<h1>Hello, world!</h1>

class MoreDrawings(grok.View):
    grok.layer(rotterdam) # override module level skin

    def render(self):
        return "Pretty"

# if no layer is specified IDefaultBrowserLayer is used

You can check it out at:

This implementation departs from docs/skin.py in that it accepts 
interface declarations not strings. The advantage to this approach is 
that it works with Zope3 as is. Personally I think Phillip's simplified 
skinning approach is wonderful and very easy to understand.

Some possibilities in keeping with the spirit of the simplified skinning 

class  DebugLayer(grok.Layer):

class PublicLayer(grok.Layer):

class PublicSkin(PublicLayer):
    grok.skin('Public')   # ++skin++Public

class DevSkin(PublicLayer, DebugLayer):
    grok.skin('Dev')   # ++skin++Dev

Let me know what you think.

Kevin Smith
Grok Groupie

More information about the Grok-dev mailing list