I have several components and now I want to add ImportExport
funcionality to some of them.
So I created a simple interface called IImportExport:
Now, all I have to do is write an adapter for each component I want to
make importable/exportable. Piece of cake:
__used_for__ = IMyComponent
def importFromFile(self, filename):
def exportToFile(self, filename):
and in the zcml:
So far so good.
Now the problem: I have a view for IImportExport objects. It just lets
the user choose a name for the file and execute the import or export
method. I want this view to appears in the ZMI tabs for every object
that has an adapter to IImportExport.
If I use implements(IImportExport) in MyComponent class even when it
does not implements IImportExport directly but trough an adapter I can
see the view for objects of type IMyComponent *but* instead of doing
I have to write
adapter = zope.component.getAdapter(object, IImportExport)
This is not so bad. The real problem is that I have to modify the
original IMyCompoment component to tell zope it implements IImportExport
even when this is false. The adapter does it, not the compoment. But I
don't know other way to make my view work with my components.
I hope I made myself clear. Best regards.
Zope3-users mailing list