[Grok-dev] @grok.traverse versus traverse

Christian Theune ct at gocept.com
Thu Oct 19 07:54:28 EDT 2006


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.


gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20061019/463a373c/signature.bin

More information about the Grok-dev mailing list