[Grok-dev] Re: grok.layer branch

Philipp von Weitershausen philipp at weitershausen.de
Tue Apr 17 09:43:33 EDT 2007

kevin at mcweekly.com wrote:
> Ok, so I went ahead and implemented the skin registration as well but 
> with caveats.
> Unfortunately the following approach is not possible without some kind 
> of dynamic interface creation.

If you use something other than the "class" statement to define layers 
or skins, you'll have to dynamically create an interface.

> 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
> grok.Layer is simply a subclass of interface.Interface,

It should be a subclass of IBrowserRequest.

> so grok.skin('Dev') raises a concrete attributes not allowed error.


> The following pattern works...
> class  Debug(grok.Layer):
>     pass
> class Public(grok.Layer):
>     pass
> class Dev(Public, Debug):
>     pass
> grok.defineskin('Public', Public) # ++skin++Public
> grok.defineskin('Dev', Debug)     # ++skin++Dev

I wonder why you call this *define*skin. You're actually not defining 
the skin here, you're just registering a layer as a skin.

> class DebugView(grok.View):
>     grok.layer(DebugLayer) #also settable at module level
> Functional tests are defined and pass, unit tests still need to be 
> defined. Perhaps grok.defineskin should be grok.define_skin


> and grok.layer may be clearer as grok.use_layer or grok.set_layer.

When we came up with "grok.context()", my argument for calling it that 
way was that the object it makes a declaration for will be 
"self.context" on the adapter/view/...

So why not call it "grok.request()"?

http://worldcookery.com -- Professional Zope documentation and training

More information about the Grok-dev mailing list