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

Class FeedHandler

source code

object --+
         |
        FeedHandler

Instance Methods [hide private]
 
__init__(self)
Provides a simple API to manipulate the collection feed as well as a public feed associated to the collection.
source code
 
init_public(self, collection=None, entry_processor=None, post_processor=None, member_class=<class 'amplee.atompub.member.MemberResource'>)
Initializes the public feed from the collection feed.
source code
 
set_public_xslt(self, path)
Adds a processing instruction to the public feed to enable XSLT processing of the feed by the consumer.
source code
 
set_collection_xslt(self, path)
Adds a processing instruction to the collection feed to enable XSLT processing of the feed by the consumer.
source code
 
_update_date(self, root) source code
 
add(self, entry)
Adds an entry to the public feed.
source code
 
remove(self, entry)
Removes the entry from the feed
source code
 
replace(self, entry)
Replaces an entry within the feed
source code
string
public_xml(self, indent=False)
Returns a byte string of the public feed or None if the feed was not set yet.
source code
 
set(self, feed)
Replaces the collection feed instance by the one provided in parameter.
source code
amara.bindery.root_base
retrieve(self)
Returns the collection feed as a amara.bindery.root_base instance
source code
string
collection_xml(self, indent=False)
Returns a byte string of the collection feed or None if the feed was not set yet.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

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.

Eeach collection may enable this handler via their feed_handler attribute. The public feed must 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. The lock cannot be acquired recursively by a given caller.

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

init_public(self, collection=None, entry_processor=None, post_processor=None, member_class=<class 'amplee.atompub.member.MemberResource'>)

source code 
Initializes the public feed from the collection feed. It also adds an atom:generator element.
Parameters:
  • collection (AtomPubCollection) - if provided it also adds an app:collection element to allow the retrieval of the collection URI.
  • entry_processor (callable) - takes one single parameter as member resource. It must return an amara.bindery.root_base 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.
  • post_processor (callable) - takes a amara.bindery.root_base instance representing the public feed. The callable should return a amara.bindery.root_base instance after post processing if needed on the public feed.
  • member_class (class) - used to generate the member for each loaded entry. By default it uses MemberResource. If you have sub-classed it, make sure you pass it here too.

set_public_xslt(self, path)

source code 
Adds a processing instruction to the public feed to enable XSLT processing of the feed by the consumer.
Parameters:
  • path (string) - URI or path to the XSLT resource. You must ensure that the path will not break the XML validity.

set_collection_xslt(self, path)

source code 
Adds a processing instruction to the collection feed to enable XSLT processing of the feed by the consumer.
Parameters:
  • path (string) - URI or path to the XSLT resource. You must ensure that the path will not break the XML validity.

add(self, entry)

source code 
Adds an entry to the public feed.
Parameters:
  • entry (amara.bindery.root_base) - atom entry to be added at the top of the feed.

remove(self, entry)

source code 
Removes the entry from the feed
Parameters:
  • entry (amara.bindery.root_base) - atom entry to remove from the feed

replace(self, entry)

source code 
Replaces an entry within the feed
Parameters:
  • entry (amara.bindery.root_base) - atom entry that needs to be replaced. This will look up the entry within by its atom:id. If it doesn't exist, the feed is not updated.

public_xml(self, indent=False)

source code 
Returns a byte string of the public feed or None if the feed was not set yet.
Parameters:
  • indent (bool) - True to indent the document
Returns: string
XML document representing the public feed

set(self, feed)

source code 
Replaces the collection feed instance by the one provided in parameter.
Parameters:
  • feed (amara.bindery.root_base) - Collection feed.

retrieve(self)

source code 
Returns the collection feed as a amara.bindery.root_base instance
Returns: amara.bindery.root_base
the collection feed

collection_xml(self, indent=False)

source code 
Returns a byte string of the collection feed or None if the feed was not set yet.
Parameters:
  • indent (bool) - True to indent the document
Returns: string
XML document representing the public feed