[Zope3-dev] A generic Decorator class

Martijn Faassen faassen@vet.uu.nl
Wed, 20 Feb 2002 19:14:26 +0100


Steve Alexander wrote:
> This email is moderately long. It explains the generic Decorator class 
> I've written. I'd like to check Decorator.py into Zope3 somewhere, and 
> I'm seeking opinions on this.

[snip]

I'm a bit late in this thread. 

I have some experience with this issue, though you're decorating content
objects together and put the view on top, instead of decorating 
a content object with a view, which is what happens to DOM nodes in
ParsedXML.

I think this kind of technique can be useful, though it can get very
messy as you run into namespace spillover issues if you aren't careful
('where's this method coming from' becomes more difficult). Another caveat
that if used a lot it can slow things down a lot.

Note also that one can use acquisition to accomplish this kind of layering
as well, which is more efficient, though has some other issues (if you're
depending on acquisition hierarchy in code you screw it up by adding
unexpected objects like this).

Regards,

Martijn