[Grok-dev] Re: grok.layer branch
Philipp von Weitershausen
philipp at weitershausen.de
Tue Apr 17 13:37:41 EDT 2007
Leonardo Rochael Almeida wrote:
> On 4/17/07, Philipp von Weitershausen <philipp at weitershausen.de> wrote:
>> kevin at mcweekly.com wrote:
>> > [...]
>> > 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.
> If I may, why not:
> class Public(grok.Layer):
> """ The Public skin, with a skin name defined in the decorator"""
> class Dev(Public, Debug):
> """ The Development Skin, with a name defined implicitly by the
> class name """
Unfortunately Python doesn't support class decorators.
>> > 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()"?
> IMHO, the intent of grok.context(SomeClassOrInterface) is clear
> enough. grok.request(SomeLayer) doesn't seem that clear, at least not
> for me...
It sets a constraint on the view's "request" attribute. That's what
> I'd suggest grok.for_layer() or grok.at_layer()
Let's avoid underscores where we can.
http://worldcookery.com -- Professional Zope documentation and training
More information about the Grok-dev