feed the masses

83
Paul Bugni Center for Public Health Informatics Feed the Masses T: 206.221.7444 F: 206.616.5249 1100 NE 45 th Street, Ste 405 Seattle, WA 98105 www.cphi.washington. edu Introducing Vice - Outbound Syndication in Plone via the Zope Component Architecture

Upload: pbugni

Post on 23-Jan-2015

1.685 views

Category:

Technology


1 download

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.

TRANSCRIPT

Page 1: Feed the Masses

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

Page 2: Feed the Masses

Agenda

• Syndication

• Vice History and Demonstration

• Zope Component Architecture

• Vice Integration

• Customizing Syndication

Page 3: Feed the Masses

What is syndication?

Page 4: Feed the Masses

To publish or broadcast

• Alternative to browser only audience for publishing content

Page 5: Feed the Masses

“Web Feed” or “News Feed”

Page 6: Feed the Masses

Data format for frequently updated content

Page 7: Feed the Masses

Content distributors syndicate a web feed

Page 8: Feed the Masses

Users can easily subscribe to the feed

Page 9: Feed the Masses

Simplifies keeping up with changes

Page 10: Feed the Masses

Using Aggregators

Page 11: Feed the Masses
Page 12: Feed the Masses
Page 13: Feed the Masses

Prevailing syndication formats

• That’s the beauty of standards, there are so many to pick from!

Page 14: Feed the Masses

Two prevailing formats (as of mid-2005)

• RSS 2.0

• Atom 1.0

Page 15: Feed the Masses

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

Page 16: Feed the Masses

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)

Page 17: Feed the Masses

First, there was the mark up language RDF

• Resource Description Framework

• Used to store metadata (author, language, copyright…) about the content

Page 18: Feed the Masses

RSS 0.90

• In 1999 Netscape created the standard named RSS version 0.90

• The beginning of RSS as we know it today

Page 19: Feed the Masses

RSS 0.91 (part 1)

• Dan Libby (Netscape) improved 0.90 and released RSS version 0.91

Page 20: Feed the Masses

RSS 0.91 (part 2)

• Dave Winer (Userland) also created an improvement of RSS 0.90 and called his version 0.91

Page 21: Feed the Masses

Confusion ensued

• Two versions named RSS 0.91 with different specifications

Page 22: Feed the Masses

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

Page 23: Feed the Masses

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

Page 24: Feed the Masses

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.

Page 25: Feed the Masses

Atom 1.0

• In part, motivated by the desire to be free of the RSS confusion

Page 26: Feed the Masses

Atompub Working Group

Page 27: Feed the Masses

IETF (Internet Engineering Task Force)

Page 28: Feed the Masses

The Atom syndication format has been adopted as IETF

Proposed Standard RFC 4287

Page 29: Feed the Masses

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

Page 30: Feed the Masses

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)

Page 31: Feed the Masses

PLIP #128 Motivation

• The current portal_syndication tool [only supports RSS 1.0 format and therefore] doesn’t have support for enclosures

Page 32: Feed the Masses

PLIP #128 Motivation (continued)

• [No current support to] extend syndication beyond common object attributes (i.e.Title, description, body etc.)

Page 33: Feed the Masses

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)

Page 34: Feed the Masses

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)

Page 35: Feed the Masses

Vice to the Rescue!

Page 36: Feed the Masses

And the name ?

• Before vice, there was “CMFSin”, “basesyndication”, “fatsyndication”, “synz”…

• “Vice was the cleanest name we could come up with.”

Page 37: Feed the Masses

Vice was Born at the (now infamous) BBQ Sprint

• Participants– Derek Richardson– Liz Dahlstrom– Mikel Larreategi– Jørgen Gårdsted

Jørgensen– Paul Bugni

Page 38: Feed the Masses

Then Vice Picked up a Sponsor

• Derek Richardson (student)

• Florian Schulze (mentor)

• Report: http://www.openplans.org/projects/vice/google-summer-of-code-report

Page 39: Feed the Masses

Vice also benefited from additional sprints

• Plone4Artist Multimedia Sprint

• 2007 Plone Conference Sprint

Page 40: Feed the Masses

Installing Vice

Page 41: Feed the Masses

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

Page 42: Feed the Masses

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

Page 43: Feed the Masses

That’s It?

• Well, it should be, but Zope2 is not yet “eggified” and vice has dependencies related to Zope3 eggs

Page 44: Feed the Masses

Workaround:

• Add “fake_zope_eggs = true” to the [zope2] section of your buildout

Page 45: Feed the Masses

Re-run ./bin/buildout

Page 46: Feed the Masses

Install Product in Portal

• Install “Outbound Syndication (Vice)”

Page 47: Feed the Masses

Configure for Use

• From the plone_control_panel (site setup)…

• Find the syndication “configlet” listed in the add on product configuration

• Enable syndication

Page 48: Feed the Masses

Out of the box demo

< break to vice demo >

Page 49: Feed the Masses

Design Goals

• So which format do we architect around?

Page 50: Feed the Masses

Ideally, none of them!

Page 51: Feed the Masses

Separation of Concerns

• Goal: separate the action of syndication from any particular format

Page 52: Feed the Masses

Goal: Make it easy to add additional feed types

Page 53: Feed the Masses

Goal: Make it easy to extend beyond common object

attributes

Page 54: Feed the Masses

How to Manage the Complexity?

• Idea: isolate behavior in “objects” dedicated to a single purpose.

Page 55: Feed the Masses

The Previous Approach:

• Use multiple inheritance to mix and match objects (create mix-ins)

• Subclass the mix-ins for further customizations

Page 56: Feed the Masses

The Downsides

• Complexity: objects built from a large number of base classes

• Lack of cohesion: lots of unrelated attributes and methods

Page 57: Feed the Masses

A Better Way

• Introducing the Zope Component Architecture

Page 58: Feed the Masses

Three Core Concepts

• Interfaces

• Components

• Adapters

Page 59: Feed the Masses

Interfaces

• A formal description of how to interact with an object

• Can be as simple as a label, or “marker”

Page 60: Feed the Masses

Components

• An “object” with introspective interfaces

Page 61: Feed the Masses

Adapters

• Inexpensive mechanism to add behavior (defined in interfaces) to existing components

• Extends a components functionality without modifications to the component

Page 62: Feed the Masses

Types of Components

• Content Components

• View Components

• Adapter Components

• Utility Components

Page 63: Feed the Masses

Zope Component Architecture

• Web Component Development with Zope 3, 3rd ed.

• Philipp von Weitershausen

Page 64: Feed the Masses

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)

Page 65: Feed the Masses

IFeedable

• Mark all folders as being “feedable”:

<class class="zope.app.folder.Folder">

<implements interface=".interfaces.IFeedable" />

</class>

Page 66: Feed the Masses

IFeed

• Represents a “Feed”

• Use to adapt objects that can provide items to feed

Page 67: Feed the Masses

IFeed

class IFeed(Interface):

"""A syndication feed e.g. RSS, atom, etc. To syndicate a container,

adapt it to IFeed.

"””

Page 68: Feed the Masses

IFeed Adapters

• Adapted to the Plone Site Root

• All Folders (IATFolder)

Page 69: Feed the Masses

IFeedItem

• Represents a single item, or entry in a feed

Page 70: Feed the Masses

IFeedItem

class IFeedItem(Interface):

"""A single syndication feed item.

""”

Page 71: Feed the Masses

IFeedItem Adapters

• Adapted to the respective AT Content Types:– IATDocument– IATEvent– IATLink– IATImage– IATFile– IATNewsItem

Page 72: Feed the Masses

Thus Vice Handles all AT Content Types “out of the box”• This includes any customized ATCT

subclasses

Page 73: Feed the Masses

How to Syndicate a New Type

Page 74: Feed the Masses

New Type Must Be Adaptable to IFeedItem

Page 75: Feed the Masses

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>

Page 76: Feed the Masses

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 77: Feed the Masses

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>

Page 78: Feed the Masses

That’s It

• < break to demo using example.dexterity >

Page 79: Feed the Masses

Adding a new Feed Format

• This trivial act is left as an exercise for the reader

Page 80: Feed the Masses

But there’s a vice sprint going on this weekend!

• http://www.openplans.org/projects/plone-conference-2008-dc/vice

Page 81: Feed the Masses

Inbound Story?

• Ajax approach: plone.syndication.inbound

• Persistent approach: feedfeeder– http://plone.org/products/feedfeeder

Page 82: Feed the Masses

How to get involved

• Did I mention the sprint?

• Join the mailing lists:

• http://www.openplans.org/projects/vice/lists– Developer list: [email protected]– Discussion list: vice-

[email protected]

Page 83: Feed the Masses

Questions?