[Zope3-dev] "common" or "basic" interface types?
Steve Alexander
steve@cat-box.net
Thu, 13 Mar 2003 11:37:07 +0200
Mike C. Fletcher wrote:
> Wondering if anyone can point me at where in Zope3 I can find the
> Interface definitions for the various "simple" types:
>
> * string, unicode (ISliceable, IIterable, IGetIndexable,
> IFindStringable, IStringInterpolatable, IStringConcatenable,
> IEtceteras)
> * list (IReverseable, IAppendContainer, IInsertByIndexContainer,
> IEtceteras)
> * dictionary ...
> * function, method, class, module ...
> * ...
Most of the interfaces you list don't exist in Zope's interface package.
Perhaps they should.
Most of the standard exceptions in Python have interfaces. These are
declared in a hierarchy that mirrors the exceptions' class hierarchy.
See src/zope/interface/common/interfaces.py
Maybe you'd like to write a proposal about providing suitable interfaces
for a range of builtin types?
> I'm looking at adopting the Zope interface mechanism for my GUI
> application-development library, and figure that I will eventually want
> these interface-types. Since I would like to keep the duplication of
> effort and incompatibility to a minimum, I would like to use the same
> interface declarations as Zope, but I don't see where in the interfaces
> package they would logically be stored.
src/zope/interface/common/
> Secondary question:
>
> When declaring an interface-set for a base-type object (one which
> cannot be directly modified to declare its interfaces)
You can declare interfaces for a class outside of the module that the
class is defined in.
See the example with exceptions that I mentioned above.
> you want to say is: I can make this type act like it has this
> interface via an adapter. Is this the proper way to go about it:
You probably don't want to say that, in this case.
But, see the IAnnotatable / IAnnotations interfaces in Zope 3 for an
example of this kind of pattern.
--
Steve Alexander