[Zope3-dev] Twisted framework refactored

Phillip J. Eby pje@telecommunity.com
Sun, 21 Apr 2002 10:29:20 -0500


At 12:47 PM 4/21/02 +0100, Steve Alexander wrote:
>Phillip J. Eby wrote:
>>The difference, for anyone who cares, is that Twisted specifically 
>>considers '__implements__' to be a *class* attribute, not an instance 
>>attribute.
>
>I'd say __implements__ should be an object attribute. So, a module can 
>implement something. An object() can implement something, by setting 
>appropriate attributes on it, and setting its __implements__ attribute.
>
>In Python 2.2, a function can implement something:
>
> >>> from Interface import Interface
> >>> l = lambda: 1
> >>> l.__dict__['__implements__'] = Interface
> >>> l.__implements__
><Interface Interface._Interface.Interface at 81a94a4>
> >>>
>
>
>Specifically considering __implements__ to be a class attribute is wrong, 
>as it adds an unnecessary dependency between the type of an object, and 
>its contractual obligations.

I agree; that's part of why I was disappointed with Twisted's 
re-implementation.  If they're going to have different semantics, it'd be 
nice if they named the attribute differently so the two systems could 
co-exist.  Perhaps we should be posting this to the twisted mailing list 
instead, though.