Philipp von Weitershausen wrote:
>Jean-Marc Orliaguet wrote:
>>is the order of the list of interfaces implemented by an object subject
>>to internal changes?
>>I have identified the need for such a pattern:
>> iface = object.interface()
>> implements(IMainInterface, ISecondaryInterface, ...)
>> def interface():
>> """Return the most specific interface implemented by the element."""
>> return list(providedBy(self))
>>to be able in that case to get access to the first interface implemented
>>by an object, as a sort of main object type.
>We usually do this differently. If some interfaces are special types
>(e.g. IFile is a content type) then we have this interface provide
>ISpecialType (e.g. IFile provides IContentType). ISpecialType is an
>interface extending IInterface.
>Then, no matter where in the list of provided interfaces the type is, it
>can be fetch with queryType. Let's take the IFile example from above and
>set it up as a content type:
> >>> from zope.app.content.interfaces import IContentType
> >>> from zope.app.file.interfaces import IFile
> >>> from zope.interface import directlyProvides
> >>> directlyProvides(IFile, IContentType)
I see, this is clever, and it simplifies the code.
the idea is that you define as many categories as you need: IMetaType,
ISomeCategory, IWidgetType ... and you create relations between
as if you had a relation tool, then every object that implements IFile
(no matter in what position) will have the IFile content type?
But where do you put the 'directlyProvides' statement? in the class :
or in the code? as with:
does it apply to the class in which the code is located in that case? I
suppose that the directlyProvide statement executed last is the one that
Zope3-dev mailing list