Based on the documentation on interfaces, I assumed that I could do the following to add an interface to an existing content:
import transaction
from plone import api
from zope.component.hooks import setSite
from Products.Five.utilities.marker import mark
from plone.app.contenttypes.interfaces import IFolder
setSite(app['test'])
portal = api.portal.get()
obj = api.content.get(path='/committees/a-committee')
mark(obj, IFolder)
transaction.commit()
However, the content did not inherit the property of the IFolder interface.
Why am I doing this? You might ask. The event portlet queries content type that implements the IFolder and ICollection interfaces. In my Plone setup, there's a committee content type that didn't implement the IFolder interface initially. I've updated the content type to implement IFolder interface, but only new committee content are affected by this change. Therefore, I'm trying to make this change reflects in existing content as well.
You probably just need to reindex your committee content items so that their entries in the object_provides index are updated.
(The right way to add a marker interface is alsoProvides from zope.interface, but I don't think you actually want to do that here. If you reindex the items it should include interfaces that are implemented by the content type class in addition to interfaces provided by particular instances.)
Ditto.
I'll add that I've never seen from Products.Five.utilities.marker import mark before, so I wonder why the docs recommend that instead of alsoProvides.
For the content type, I actually didn't use alsoProvides, I did this:
from zope.interface import implementer
from plone.dexterity.content import Container
from plone.app.contenttypes.interfaces import IFolder
@implementer(IFolder)
class Committee(Container):
pass
When I checked, http://plone/a-committee/mange_interfaces*, I see the IFolder interface in the list of active interfaces, yet it still doesn't show up in the event portlet search base for existing committee content that has events. I know it works for new committee content.