Package amplee :: Package atompub :: Module collection :: Class FeedHandler
[show private | hide private]
[frames | no frames]

Type FeedHandler

object --+
         |
        FeedHandler


Method Summary
  __init__(self)
Provides a simple API to manipulate the collection feed as well as a public feed associated to the collection.
  add(self, entry)
  collection_xml(self)
Returns a byte string of the collection feed or None if the feed was not set yet.
  init_public(self, collection, entry_processor, post_processor)
Initializes the public feed from the collection feed.
  public_xml(self)
Returns a byte string of the public feed or None if the feed was not set yet.
  remove(self, entry)
  replace(self, entry)
  retrieve(self)
Returns the collection feed as a bridge.Document instance
  set(self, feed)
Replaces the collection feed instance by the one provided in parameter.
  set_collection_xslt(self, path, add_extra_comment)
Adds a processing instruction to the collection feed to enable XSLT processing of the feed by the consumer.
  set_public_xslt(self, path, add_extra_comment)
Adds a processing instruction to the public feed to enable XSLT processing of the feed by the consumer.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__init__(self)
(Constructor)

Provides a simple API to manipulate the collection feed as well as a public feed associated to the collection.

The public feed usually holds public views of the member entries and targets aggregators or other read-only consumer that don't understand the AtomPub protocol. The API to manipulate the feed will automatically update the atom:updated value of the feed.

By default each collection enables this handler via their feed_handler attribute. The public feed mus be explicitely initialized by a call to init_public().

You can also attach an XSLT document if you want the consumer to automatically transforms teh public feed into another XML document, often XHTML.

Each write operation is synchronized by an internal lock, however the read operation is not for optimization purpose.

You may re-implement this class if you have special needs but there should not be any.
Overrides:
__builtin__.object.__init__

collection_xml(self)

Returns a byte string of the collection feed or None if the feed was not set yet.

init_public(self, collection=None, entry_processor=None, post_processor=None)

Initializes the public feed from the collection feed. It also adds an atom:generator element.

If the ``collection`` parameter is provided it also adds an app:collection element to allow the retrieval of the collection URI.

The ``entry_processor`` if provided is a callable that takes one single parameter as member resource. It must return a bridge.Element that will be added to the public feed in place of the one passed in parameter.

This can be useful if you have to pre-process the entry before it being inserted to the public feed.

You can also return None to prevent the entry to be inserted at all.

The ``post_processor`` should be a callable that takes a bridge.Document instance representing the public feed. The callable should return a bridge.Document instance after post processing if needed on the public feed.

public_xml(self)

Returns a byte string of the public feed or None if the feed was not set yet.

retrieve(self)

Returns the collection feed as a bridge.Document instance

set(self, feed)

Replaces the collection feed instance by the one provided in parameter. Wraps the bridge.Element provided into a bridge.Document instance

set_collection_xslt(self, path, add_extra_comment=False)

Adds a processing instruction to the collection feed to enable XSLT processing of the feed by the consumer.

The ``path`` argument is the URI or URI path to the XSLT resource. You must ensure that the path will not break the XML validity.

Set the ``add_extra_comment`` parameter to True to force a comment of 512 bytes to be added and ensure older browsers do treat the processing instruction.

set_public_xslt(self, path, add_extra_comment=False)

Adds a processing instruction to the public feed to enable XSLT processing of the feed by the consumer.

The ``path`` argument is the URI or URI path to the XSLT resource. You must ensure that the path will not break the XML validity.

Set the ``add_extra_comment`` parameter to True to force a comment of 512 bytes to be added and ensure older browsers do treat the processing instruction.

Generated by Epydoc 2.1 on Thu Jul 19 15:32:17 2007 http://epydoc.sf.net