[Zope3-Users] Re: How to manually define an object's provided interfaces?

Philipp von Weitershausen philipp at weitershausen.de
Tue May 30 04:30:16 EDT 2006


Janko Hauser wrote:
>> OK - this was a bit confusing. One more try:
>>
>>  I want to make an object provided one interface (IFile) always and one
>>  interface (IImage) "sometimes". Sometimes means "whenever libmagic
>> thinks,
>>  the file is an Image". I don't want to modify any interface but only the
>>  object's list of provided interfaces.
> 
> So it's an additional interface. Look up the usage of
> "directlyProvides', with this, one can set additional interfaces on an
> instance.

I would recommend using (and advocating) alsoProvides because
directlyProvides REsets all marker interfaces. alsoProvides only adds
them and won't remove any.

> It is often used for marker interfaces. This would also be a
> hint for your problem, only set a marker on the file object, so that
> image related adapters could be used for this marked instance.

Yup.

Philipp



More information about the Zope3-users mailing list