assembl.models.feed_parsing module

Utilities for extracting posts and from a RSS or Atom feed.

class assembl.models.feed_parsing.FeedFetcher[source]

Bases: object

A thin wrapper around requests in order to be able to get a feed from a web resource address, returning either as a string object (which is the preferred method for feedparser) or as a StringIO object (which is what speedparser likes)

return_file(uri)[source]

Returns a StringIO with the xml inside

return_string(uri)[source]

Returns the string content with the xml inside

class assembl.models.feed_parsing.FeedPost(*args, **kwargs)[source]

Bases: assembl.models.post.ImportedPost

A discussion post that is imported from an external feed source.

body_mime_type

The mime type of the body of the imported content. See Content::get_body_mime_type() for allowed values.

message_id

The email-compatible message-id for the post.

source_post_id

The source-specific unique id of the imported post. A listener keeps the message_id in the post class in sync

class assembl.models.feed_parsing.FeedPostSource(**kwargs)[source]

Bases: assembl.models.generic.PostSource

The source of an imported feed, be it Atom, RSS, or any other type of feed protocol.

post_type

alias of assembl.models.feed_parsing.FeedPost

send_post(post)[source]

Send a new post in the discussion to the source.

user_type

alias of assembl.models.feed_parsing.WebLinkAccount

class assembl.models.feed_parsing.LoomioAccount(**kwargs)[source]

Bases: assembl.models.feed_parsing.WebLinkAccount

An imported Loomio name and address. This is not an authenticated user.

class assembl.models.feed_parsing.LoomioFeedPost(*args, **kwargs)[source]

Bases: assembl.models.feed_parsing.FeedPost

A discussion post this is imported from a feed extracted from Loomio.

body_mime_type

The mime type of the body of the imported content. See Content::get_body_mime_type() for allowed values.

message_id

The email-compatible message-id for the post.

source_post_id

The source-specific unique id of the imported post. A listener keeps the message_id in the post class in sync

class assembl.models.feed_parsing.LoomioPostSource(**kwargs)[source]

Bases: assembl.models.feed_parsing.FeedPostSource

The source an imported feed, that came directly from Loomio.

post_type

alias of assembl.models.feed_parsing.LoomioFeedPost

send_post(post)[source]

Send a new post in the discussion to the source.

user_type

alias of assembl.models.feed_parsing.LoomioAccount

class assembl.models.feed_parsing.PaginatedParsedData(url, parser_wrapper=None, page_key='page', start_page=1)[source]

Bases: assembl.models.feed_parsing.ParsedData

Extention of the “Data Getter” object, which supports basic pagination of data.

@TODO: Extend this object to support variable key pagination, rather than simple integer incrementation.

class assembl.models.feed_parsing.ParsedData(url, parser_wrapper=None)[source]

Bases: object

For every atom feed URL that is fetched, a ParsedData object is generated to handle the retrieving the feed, the entries, or other fields as needed. This object is the base “Data Getter” object for atom feeds.

@TODO: Extend this class to suport RRS feeds as well.

get_feed()[source]

Returns feed summary from entire parsed feed as list

get_parsed_feed()[source]

Returns the entire parsed feed as a dict

class assembl.models.feed_parsing.ParserWrapper(fetcher, parser, parser_can_read_file=False)[source]

Bases: object

A moderate wrapper around which parsing module is used (feedparser vs speedparser).

class assembl.models.feed_parsing.WebLinkAccount(**kwargs)[source]

Bases: assembl.models.auth.AbstractAgentAccount

An imported name that has not been validated nor authenticated within the platform. This is to keep track of an imported post’s ownership.

unique_query()[source]

returns a couple (query, usable), with a sqla query for conflicting similar objects. usable is true if the query has to be enforced; sometimes it makes sense to return un-usable query that will be used to construct queries of subclasses. Note that when a duplicate is found, you’ll often want to expunge the original.