View
1.687
Download
1
Category
Preview:
DESCRIPTION
This talk will introduce the audience to Vice http://www.openplans.org/projects/vice/project-home a cutting-edge solution to all outbound syndication needs for Plone 3.1+, providing RSS 1.0, RSS 2.0, and Atom feed formats for all built in content types.
Citation preview
Paul BugniCenter for Public Health Informatics
Feed the Masses
T: 206.221.7444F: 206.616.5249
1100 NE 45th Street, Ste 405Seattle, WA 98105
www.cphi.washington.edu
Introducing Vice - Outbound Syndication in Plonevia the Zope Component Architecture
Agenda
• Syndication
• Vice History and Demonstration
• Zope Component Architecture
• Vice Integration
• Customizing Syndication
What is syndication?
To publish or broadcast
• Alternative to browser only audience for publishing content
“Web Feed” or “News Feed”
Data format for frequently updated content
Content distributors syndicate a web feed
Users can easily subscribe to the feed
Simplifies keeping up with changes
Using Aggregators
Prevailing syndication formats
• That’s the beauty of standards, there are so many to pick from!
Two prevailing formats (as of mid-2005)
• RSS 2.0
• Atom 1.0
Exposing the myth of RSS compatibility
• “I would like to publicly apologize for my previous misstatements. There are not 7 different and incompatible versions of RSS; there are 9” - Mark Pilgrim[1]
[1] http://diveintomark.org/archives/2004/02/04/incompatible-rss
RSS Stands For?
• RDF (Resource Description Framework) Site Summary (RSS 1.0 and RSS 0.90)
• Rich Site Summary (RSS 0.91)
• Really Simple Syndication (RSS 2.0)
First, there was the mark up language RDF
• Resource Description Framework
• Used to store metadata (author, language, copyright…) about the content
RSS 0.90
• In 1999 Netscape created the standard named RSS version 0.90
• The beginning of RSS as we know it today
RSS 0.91 (part 1)
• Dan Libby (Netscape) improved 0.90 and released RSS version 0.91
RSS 0.91 (part 2)
• Dave Winer (Userland) also created an improvement of RSS 0.90 and called his version 0.91
Confusion ensued
• Two versions named RSS 0.91 with different specifications
RSS 1.0
• Rael Dornfest (O’Reily) released RSS version 1.0
• Based on the RDF standard rather than RSS
• RSS 1.0 was therefore incompatible with previous RSS versions
So to clear things up
• Userland named their next release version 2.0
• Harvard Law accepted responsibility for the RSS 2.0 specification
• RSS 2.0 is very similar to 0.9 series (generally compatible)
• RSS 1.0 remains very different
RSS 2.0
• The specification is copyrighted by Harvard University and is frozen.
• The intent is that future work will be done under a different name.
Atom 1.0
• In part, motivated by the desire to be free of the RSS confusion
Atompub Working Group
IETF (Internet Engineering Task Force)
The Atom syndication format has been adopted as IETF
Proposed Standard RFC 4287
RSS 2.0 versus Atom 1.0
• A number of ambiguities exist in RSS 2.0 including:– No required fields (Atom requires title unique id and last updated)– No way to indicate if payload is encoded or plain text (Atom
requires explicit declaration and includes options such as another XML vocabulary)
– Autodiscover is not standardized and relies on an unregistered MIME type
– Only Atom 1.0 is in an XML namespace and has specific guidelines for interpreting extension elements. (RSS 2.0 does not permit well formed XML markup)
• http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared
Need For Better Syndication in Plone
• 2006-Feb-01 PLIP #128 was born– PLIP: Plone Improvement Proposal,
analogous to python’s PEPs: Python Enhancement Proposal
• #128: Pluggable Plone Syndication (PPS)
PLIP #128 Motivation
• The current portal_syndication tool [only supports RSS 1.0 format and therefore] doesn’t have support for enclosures
PLIP #128 Motivation (continued)
• [No current support to] extend syndication beyond common object attributes (i.e.Title, description, body etc.)
PLIP #128 Motivation (continued)
• [No current support for] different types of feed entries for different content types (i.e. enclosures for media content a.k.a. podcasting)
PLIP #128
• Enable advanced (RSS 2.0, Atom) site-wide syndication on all ATCT content “out-of-the-box” using Zope 3-based adaptors (via Five) which are extendable beyond ATCT to any content type.
• (ATCT : ATContent Types)
Vice to the Rescue!
And the name ?
• Before vice, there was “CMFSin”, “basesyndication”, “fatsyndication”, “synz”…
• “Vice was the cleanest name we could come up with.”
Vice was Born at the (now infamous) BBQ Sprint
• Participants– Derek Richardson– Liz Dahlstrom– Mikel Larreategi– Jørgen Gårdsted
Jørgensen– Paul Bugni
Then Vice Picked up a Sponsor
• Derek Richardson (student)
• Florian Schulze (mentor)
• Report: http://www.openplans.org/projects/vice/google-summer-of-code-report
Vice also benefited from additional sprints
• Plone4Artist Multimedia Sprint
• 2007 Plone Conference Sprint
Installing Vice
Add Vice to the Buildout Eggs
• Using buildout, edit buildout.cfg and add vice.plone.outbound to the [eggs] section:
eggs =
elementtree
vice.plone.outbound
Include the Vice Configuration Files (a la zcml slug)
• Edit buildout.cfg and add vice.plone.outbound to the [instance] zcml
[instance]
zcml = vice.plone.outbound
That’s It?
• Well, it should be, but Zope2 is not yet “eggified” and vice has dependencies related to Zope3 eggs
Workaround:
• Add “fake_zope_eggs = true” to the [zope2] section of your buildout
Re-run ./bin/buildout
Install Product in Portal
• Install “Outbound Syndication (Vice)”
Configure for Use
• From the plone_control_panel (site setup)…
• Find the syndication “configlet” listed in the add on product configuration
• Enable syndication
Out of the box demo
< break to vice demo >
Design Goals
• So which format do we architect around?
Ideally, none of them!
Separation of Concerns
• Goal: separate the action of syndication from any particular format
Goal: Make it easy to add additional feed types
Goal: Make it easy to extend beyond common object
attributes
How to Manage the Complexity?
• Idea: isolate behavior in “objects” dedicated to a single purpose.
The Previous Approach:
• Use multiple inheritance to mix and match objects (create mix-ins)
• Subclass the mix-ins for further customizations
The Downsides
• Complexity: objects built from a large number of base classes
• Lack of cohesion: lots of unrelated attributes and methods
A Better Way
• Introducing the Zope Component Architecture
Three Core Concepts
• Interfaces
• Components
• Adapters
Interfaces
• A formal description of how to interact with an object
• Can be as simple as a label, or “marker”
Components
• An “object” with introspective interfaces
Adapters
• Inexpensive mechanism to add behavior (defined in interfaces) to existing components
• Extends a components functionality without modifications to the component
Types of Components
• Content Components
• View Components
• Adapter Components
• Utility Components
Zope Component Architecture
• Web Component Development with Zope 3, 3rd ed.
• Philipp von Weitershausen
Core Vice Concepts
• Containers (such as Folders) are “Feedable” (marked with the IFeedable interface, adaptable to the IFeed interface)
• Content Objects (such as Documents) are “Feed Items” (adaptable to the IFeedItem interface)
IFeedable
• Mark all folders as being “feedable”:
<class class="zope.app.folder.Folder">
<implements interface=".interfaces.IFeedable" />
</class>
IFeed
• Represents a “Feed”
• Use to adapt objects that can provide items to feed
IFeed
class IFeed(Interface):
"""A syndication feed e.g. RSS, atom, etc. To syndicate a container,
adapt it to IFeed.
"””
IFeed Adapters
• Adapted to the Plone Site Root
• All Folders (IATFolder)
IFeedItem
• Represents a single item, or entry in a feed
IFeedItem
class IFeedItem(Interface):
"""A single syndication feed item.
""”
IFeedItem Adapters
• Adapted to the respective AT Content Types:– IATDocument– IATEvent– IATLink– IATImage– IATFile– IATNewsItem
Thus Vice Handles all AT Content Types “out of the box”• This includes any customized ATCT
subclasses
How to Syndicate a New Type
New Type Must Be Adaptable to IFeedItem
Register the Adapter Factory
<!-- Vice demo, adapt example.dexterity.page.IPage to IFeedItem
so the example dexterity pages can be syndicated -->
<adapter
factory=".syndication.ExampleDexterityPageFeedItem"
name="vice-default"
trusted="true" />
<class class=".syndication.ExampleDexterityPageFeedItem">
<require
permission="vice.ViewFeeds"
interface="vice.outbound.interfaces.IFeedItem" />
</class>
Define the IFeedItem Adapter Class
class ExampleDexterityPageFeedItem(ExampleDexterityFeedItemBase):
""”Makes example.dexterity.page.IPage IFeedItem adaptable.
"""
implements(IFeedItem)
adapts(IPage, IFeed)
@property
def body(self):
"""See IFeedItem
"""
v = getMultiAdapter((self.context, self.context.REQUEST), Interface, name=u'syndicate_page')
return v().encode('utf-8')
Page Template for Body of Feed Item
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
i18n:domain="plone">
<body>
<p tal:content="context/Description" />
<div tal:content="structure context/body" />
</body>
</html>
That’s It
• < break to demo using example.dexterity >
Adding a new Feed Format
• This trivial act is left as an exercise for the reader
But there’s a vice sprint going on this weekend!
• http://www.openplans.org/projects/plone-conference-2008-dc/vice
Inbound Story?
• Ajax approach: plone.syndication.inbound
• Persistent approach: feedfeeder– http://plone.org/products/feedfeeder
How to get involved
• Did I mention the sprint?
• Join the mailing lists:
• http://www.openplans.org/projects/vice/lists– Developer list: vice-dev@lists.openplans.org– Discussion list: vice-
discussion@lists.openplans.org
Questions?
Recommended