[Zope3-dev] Proposal: Improving on __implements__

Phillip J. Eby pje@telecommunity.com
Sat, 18 Jan 2003 21:34:15 -0500


At 01:09 AM 1/19/03 +0200, Steve Alexander wrote:
>Hi folks,
>
>I've added a new proposal to the zope3 development wiki.
>
>It is called "Improving on __implements__'.
>
>http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/BetterInterfaceImplements
>

Just a comment on the implementation...  if you manipulate f_locals, you 
can just use the function to *set* (or change) an __implements__ 
value.  AFAIK, class body code is executed with an actual local dictionary, 
so it should be modifiable.  Thus, there's no need for a registry and all 
that other sort of thing.  In fact, you don't even need to care about the 
class name.

While in some ways, this is "more" magical, it's a simpler 
implementation.  I'm not sure how Jython is affected, but then I'm not sure 
whether Jython allows you to get at Python stack frames in the first place.

While I do like the simplified syntax, I'm also not sure that it does 
anything that you can't do like this:

class ServiceSubscriberEventChannel(SubscriptionTracker, EventChannel):
     """An event channel that wants to subscribe to the nearest
     event service when bound, and unsubscribe when unbound.
     """

implements(ServiceSubscriberEventChannel,
     (IBindingAware, EventChannel.__implements__, 
SubscriptionTracker.__Implements__)
)

While it's nice to put it in the class body, I'm not sure it's worth the 
magic.  So I'm +0 on it.