[Grok-dev] @grok.traverse versus traverse

Philipp von Weitershausen philipp at weitershausen.de
Thu Oct 19 09:27:04 EDT 2006

Christian Theune wrote:
> Hi,
> Martijn Faassen wrote:
>> Adding a decorator saves you 1 line of code and is a trifle less DRY,
>> but still, this isn't very disastrous:
>> class House(grok.Model):
>>    def traverse(self, name):
>>        return self.getWindow(name)
>> Often enough there needs to be some mangling of the name anyway, for
>> instance int(name) and whatnot. The case when you can get away with just
>> using a decorator is therefore rather limited anyway, so I'd say YAGNI
>> to that.
> Right. I forgot about the mangling. The other stuff would just be nicer
> because the method name would describe what it does, not what it is used
> for. These are two orthogonal aspects probably.
> The name mangling definitely is not model code in general, so having a
> special method that is a bit 'un-model-like' is fine with me as it
> emphasizes the distinction.

Fine with me, too. I was just following our design notes this morning 
:). While in general I think it's a good idea not to overuse decorators, 
here it was the mangling argument that won me over.

I'll look at it later tonight. I wanted to anyways because there are 
still some open issues.


More information about the Grok-dev mailing list