[Zope3-dev] A generic Decorator class

Gary Poster Gary Poster" <garyposter@earthlink.net
Sun, 17 Feb 2002 13:28:47 -0500


From: "Steve Alexander" <steve@cat-box.net>

> ---- obligatory GOF quote ----
> Decorator (p.175):
>
>    Attach additional responsibilities to an object dynamically.
> Decorators provide a flexible alternative to subclassing for extending
> functionality.
> ----                      ----

OK, forgive the guy who hasn't coded in Zope 3 yet.  This is an "edify me"
request.

Studying GoF in the past, I thought acquisition was the preferred
Zope/Python implementation of this pattern.  All the GoF decorator does is
wrap the original object to give it new functionality: e.g. (I thought)
implicit acquisition.  Then the object can in fact announce what interfaces
it provides, through acquisition.  I remember being pretty impressed at how
thorough a job acquisition did at implementing this pattern.

I know Zope 3 is moving over to explicit for default behavior, but that
doesn't mean to me that, when implicit makes sense, you don't use implicit.

So, why is another Decorator pattern necessary?  Is implicit acquisition
just frowned upon so much now, as a potentially confusing implementation,
that another approach is needed?  Or is acquisition already fulfilling
another role in this module that makes it difficult or impossible to use it
for this purpose as well?  Or do I not get something basic?

Please edify. :-)

Thanks

Gary