[Grok-dev] grok.layer branch

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


Hi,

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):
    pass

class CaveDrawings(grok.View):
    pass

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

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:
svn.zope.org/repos/main/grok/branches/ksmith_mcweekly-layers

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 
approach...

class  DebugLayer(grok.Layer):
     pass

class PublicLayer(grok.Layer):
    pass

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