[Interface-dev] module-level interface

Jim Fulton jim at zope.com
Wed Jun 8 11:27:08 EDT 2005


John Lenton wrote:
> On 6/8/05, Jim Fulton <jim at zope.com> wrote:
> 
>>Use the directlyProvides function (outside the class definition) or
>>the classProvides function (inside the function) to declare interfaces
>>provides by (as opposed to implemented by) the class.
> 
> 
> oops, sorry about the misuse of terminology: what I mean is that the
> modules and the classes must *implement* the interface.

Modules can never implement an interface because they are
not callable.

We say that a factory (commonly a class) "implements" an interface,
by which we mean that the objects created by the factory "provide"
the interface.  An object "provides" an interface if it satisfies the
specification defined by the interface.

 > For example, a
> skin module must provide a "Window" class that must implement the
> IWindow interface. Currently I'm using
> zope.interface.verify.verifyObject, and ISkin (the interface that must
> be implemented by the module) looks like this:
> 
> class ISkin(interface.Interface):
>     def Window():
>         pass
> 
> with this, verifyObject checks that the skin provides the Window
> class, but that's all; I'd like for it to check if the Window
> implements IWindow. Is that doable? (I know I could do it "by hand"
> using several verifies, but I thought I'd ask before doing
> that---maintainability would suck)

The current verification framework is very crude and not very powerful.
It alone cannot answer this question.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Interface-dev mailing list