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

Frank Burkhardt fbo2 at gmx.net
Mon May 29 06:56:48 EDT 2006


Hi,

I'm going to write an alternative implementation of
zope.app.file.interfaces.IFile . This implementation will automatically
determine the mime type of the data it's containing.

I would like to add a method that determines (guesses), if the current file
object contains an image...

 isimage=(mimetype(self.data).split('/')[0] == 'image')

... and I want to dynamically make the object implement another interface ...

 if isimage:
    IImage.provide(self)
 else:
    IImage.dontprovide(self)

Unfortunately, there is no 'provide' method on interfaces :-( .

Now the questions:

1. Is the list of a content object's provided interfaces stored persistently
   in the Zodb?
   
2. Is it according to Zope-, Python-, ... philosophy ok to danymically implement
   interfaces depending on the inner state of an object?
 
3. How do I manually make objects provide or "unprovide" given interfaces?

Regards,

Frank


More information about the Zope3-users mailing list