Miami, er, Bristol Vice
We’ve been working on the new Vice syndication project, integrating it into our new Viral Content Manager system. Although the system is still pre-alpha it is very impressive! The basic structure of our content types is:
ContentItems are contained in a folderish portal tool, and contain a reference to 0..* ContentChannels which can be anywhere.
We now have working RSS and ATOM feeds for the ContentItems associated with a given ContentChannel, looking like this:
from zope.interface import implements from zope.component import adapts, queryMultiAdapter, getMultiAdapter from zope.interface import Interface from Products.VCNArchetypes.interfaces import IChannel, IViral from plone.syndication.outbound.interfaces import IFeed, IFeedItem import logging from plone.app.syndication.outbound.adapters.atct import ATFeedBase, ATFeedItemBase class ContentFeed(ATFeedBase): """Adapter from IChannel to IFeed. >>> from zope.interface.verify import verifyClass >>> verifyClass(IFeed, ContentFeed) True """ implements(IFeed) adapts(IChannel, str) def __iter__(self): items = self.context.getContentItems() while 1: yield queryMultiAdapter((items.next(), self), IFeedItem) class ViralFeedItem(ATFeedItemBase): """Adapter from IViral to IFeedItem. Make sure that ViralFeedItem implements the IFeedItem interface >>> from zope.interface.verify import verifyClass >>> verifyClass(IFeedItem, ViralFeedItem) True """ implements(IFeedItem) adapts(IViral, IFeed) @property def url(self): return self.context.getViral_url() @property def body(self): return self.context.getViral_description() and called in with: <configure> xmlns="http://namespaces.zope.org/zope" xmlns:zcml="http://namespaces.zope.org/zcml" xmlns:five="http://namespaces.zope.org/five"></configure> <class class="Products.VCNArchetypes.ContentChannel.ContentChannel"> <implements interface="plone.syndication.outbound.interfaces.IFeedable"></implements> </class> <!-- Adapt IChannel to IFeed --> <adapter> </adapter> factory=".contentfeed.ContentFeed" trusted="true" /> <class class=".contentfeed.ContentFeed"> <require> permission="plone.syndication.ViewFeeds" interface="plone.syndication.outbound.interfaces.IFeed" /> </require></class> <!-- Adapt IViral to IFeedItem --> <adapter> </adapter> factory=".contentfeed.ViralFeedItem" trusted="true" /> <class class=".contentfeed.ViralFeedItem"> <require> permission="plone.syndication.ViewFeeds" interface="plone.syndication.outbound.interfaces.IFeedItem" /> </require></class>
One of the sprint tasks is creating an easy to follow, doctested, readme. Until that comes out hopefully this will help people use this brilliant addition to Plone!
Thanks derek_richardson, pbugni and everyone else who’s contributed!