[PEAK] Re: gf.when() doesn't honour Interfaces on instances (protocols.adviseObject)

Phillip J. Eby pje at telecommunity.com
Thu Dec 2 13:12:27 EST 2004

At 05:32 PM 12/2/04 +0100, Ulrich Eck wrote:
>Hi Phillip,
>Am Donnerstag, den 02.12.2004, 10:52 -0500 schrieb Phillip J. Eby:
> > Second, you can't use adviseObject() to add and remove
> > interfaces like that, because PyProtocols wants to have a convergent
> > interface state, and therefore never retracts interfaces in its
> > default
> > implementation.  If you need an object to change its interfaces on the
> > fly
> > you need to implement a custom __conform__ method and handle it
> > internally
> > to the object.
>this originates from the idea to be able to use *one* implementation for
>peak- and z3-component based systems (z3 with their interfaces-impl).

Well, you *can* do that , you'd just have to do the heavy lifting yourself 
in a custom __conform__.  Personally, I think using interfaces to represent 
state is, well, odd at the least.  An interface expresses a contract, but 
what is the contract of a state?  State is part of implementation, IMO, not 
part of the interface.

However, I think this is part of a systemic design bias in Zope towards 
viewing objects as dumb "content", and putting the behaviors in other 
objects that examine the "content" to decide what to do with it.  I think 
this perspective leads to flawed encapsulation, and makes it harder for 
people to extend the framework because they then have to fake metadata to 
convince the behavior objects to do what they want, when if the behavior 
were on the content object to start with it wouldn't be an issue.

(Actually, another design issue that's in play is the Zope preference for 
adapters to adapt from interface to interface, instead of implementation to 
interface.  I heard at one point they were going to allow class->interface 
adapters, but I'm not sure if that ever materialized.)

More information about the PEAK mailing list