[Mailman3-dev] PyProtocols or Zope interfaces?

Barry Warsaw barry at python.org
Mon Apr 19 21:24:30 EDT 2004


I'd like to re-open the discussion of which interfaces package we are
going to use in MM3.  Before I checked everything into the public cvs, I
was using a snapshot of Zope3 interfaces from maybe 8 months ago.  But
then I switch to PyProtocols mostly because I found it pretty difficult
to rip sub-packages out of Zope for distribution outside of Zope.

Now however, Zope3 is gaining a packaging system that should make
pulling useful stuff out of Zope much easier.  It won't necessarily
reduce inter-package dependencies, but at least it will handle them
automatically for us, and should be able to provide us with distutils
packages that we can simply include and install.

There are two things I like about Zope3 interfaces now (these are new
since the last time I stole from Zope3): calling an interface is
syntactic sugar for a PEP 246-like adapt() call, and declarations on
classes are more succinct.

For the former, it means doing something like:

from mailman.interfaces.transactions import ITransactionManager
mgr = ITransactionManager(obj, None)
if mgr is None:
  # adapt failed, or we could have omitted the second arg and
  # caught TypeError instead.

That looks nice to me!

For the latter, it means being able to say:

class SomeClass:
    implements(IFoo)

instead of the more wordy PyProtocols way (or the now-deprecated
__implements__ = IFoo).

The Z3 packaging system hasn't quite landed, but I know that it's a top
priority and near completion.  I'm inclined to switch back to Zope
interfaces when this is ready.

Also, I think the next version of PyProtocols will adopt callable
interfaces, but probably won't adopt implements().  I'll note also that
Twisted recently decided to switch to Zope interfaces, so it seems like
there might be critical mass there.

Comments?

-Barry





More information about the Mailman3-Dev mailing list