Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.contrib.atom.FeedEntry Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def generate
def to_string
def __unicode__
def __str__

Public Attributes

 title
 title_type
 content
 content_type
 url
 id
 updated
 summary
 summary_type
 author
 published
 rights
 links
 xml_base

Detailed Description

Represents a single entry in a feed.

:param title: the title of the entry. Required.
:param title_type: the type attribute for the title element.  One of
                   ``'html'``, ``'text'`` or ``'xhtml'``.
:param content: the content of the entry.
:param content_type: the type attribute for the content element.  One
                     of ``'html'``, ``'text'`` or ``'xhtml'``.
:param summary: a summary of the entry's content.
:param summary_type: the type attribute for the summary element.  One
                     of ``'html'``, ``'text'`` or ``'xhtml'``.
:param url: the url for the entry.
:param id: a globally unique id for the entry.  Must be an URI.  If
           not present the URL is used, but one of both is required.
:param updated: the time the entry was modified the last time.  Must
                be a :class:`datetime.datetime` object. Required.
:param author: the author of the feed.  Must be either a string (the
               name) or a dict with name (required) and uri or
               email (both optional).  Can be a list of (may be
               mixed, too) strings and dicts, too, if there are
               multiple authors. Required if not every entry has an
               author element.
:param published: the time the entry was initially published.  Must
                  be a :class:`datetime.datetime` object.
:param rights: copyright information for the entry.
:param rights_type: the type attribute for the rights element.  One of
                    ``'html'``, ``'text'`` or ``'xhtml'``.  Default is
                    ``'text'``.
:param links: additional links.  Must be a list of dictionaries with
              href (required) and rel, type, hreflang, title, length
              (all optional)
:param xml_base: The xml base (url) for this feed item.  If not provided
                 it will default to the item url.

For more information on the elements see
http://www.atomenabled.org/developers/syndication/

Everywhere where a list is demanded, any iterable can be used.

Definition at line 225 of file atom.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.contrib.atom.FeedEntry.__init__ (   self,
  title = None,
  content = None,
  feed_url = None,
  kwargs 
)

Definition at line 266 of file atom.py.

00266 
00267     def __init__(self, title=None, content=None, feed_url=None, **kwargs):
00268         self.title = title
00269         self.title_type = kwargs.get('title_type', 'text')
00270         self.content = content
00271         self.content_type = kwargs.get('content_type', 'html')
00272         self.url = kwargs.get('url')
00273         self.id = kwargs.get('id', self.url)
00274         self.updated = kwargs.get('updated')
00275         self.summary = kwargs.get('summary')
00276         self.summary_type = kwargs.get('summary_type', 'html')
00277         self.author = kwargs.get('author')
00278         self.published = kwargs.get('published')
00279         self.rights = kwargs.get('rights')
00280         self.links = kwargs.get('links', [])
00281         self.xml_base = kwargs.get('xml_base', feed_url)
00282 
00283         if not hasattr(self.author, '__iter__') \
00284            or isinstance(self.author, (basestring, dict)):
00285             self.author = [self.author]
00286         for i, author in enumerate(self.author):
00287             if not isinstance(author, dict):
00288                 self.author[i] = {'name': author}
00289 
00290         if not self.title:
00291             raise ValueError('title is required')
00292         if not self.id:
00293             raise ValueError('id is required')
00294         if not self.updated:
00295             raise ValueError('updated is required')


Member Function Documentation

Definition at line 296 of file atom.py.

00296 
00297     def __repr__(self):
00298         return '<%s %r>' % (
00299             self.__class__.__name__,
00300             self.title
00301         )

Definition at line 342 of file atom.py.

00342 
00343     def __str__(self):
00344         return self.to_string().encode('utf-8')

Here is the call graph for this function:

Definition at line 339 of file atom.py.

00339 
00340     def __unicode__(self):
00341         return self.to_string()

Here is the call graph for this function:

Yields pieces of ATOM XML.

Definition at line 302 of file atom.py.

00302 
00303     def generate(self):
00304         """Yields pieces of ATOM XML."""
00305         base = ''
00306         if self.xml_base:
00307             base = ' xml:base="%s"' % escape(self.xml_base, True)
00308         yield u'<entry%s>\n' % base
00309         yield u'  ' + _make_text_block('title', self.title, self.title_type)
00310         yield u'  <id>%s</id>\n' % escape(self.id)
00311         yield u'  <updated>%s</updated>\n' % format_iso8601(self.updated)
00312         if self.published:
00313             yield u'  <published>%s</published>\n' % \
00314                   format_iso8601(self.published)
00315         if self.url:
00316             yield u'  <link href="%s" />\n' % escape(self.url)
00317         for author in self.author:
00318             yield u'  <author>\n'
00319             yield u'    <name>%s</name>\n' % escape(author['name'])
00320             if 'uri' in author:
00321                 yield u'    <uri>%s</uri>\n' % escape(author['uri'])
00322             if 'email' in author:
00323                 yield u'    <email>%s</email>\n' % escape(author['email'])
00324             yield u'  </author>\n'
00325         for link in self.links:
00326             yield u'  <link %s/>\n' % ''.join('%s="%s" ' % \
00327                 (k, escape(link[k], True)) for k in link)
00328         if self.summary:
00329             yield u'  ' + _make_text_block('summary', self.summary,
00330                                            self.summary_type)
00331         if self.content:
00332             yield u'  ' + _make_text_block('content', self.content,
00333                                            self.content_type)
00334         yield u'</entry>\n'

Here is the call graph for this function:

Here is the caller graph for this function:

Convert the feed item into a unicode object.

Definition at line 335 of file atom.py.

00335 
00336     def to_string(self):
00337         """Convert the feed item into a unicode object."""
00338         return u''.join(self.generate())

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 276 of file atom.py.

Definition at line 269 of file atom.py.

Definition at line 270 of file atom.py.

Definition at line 272 of file atom.py.

Definition at line 279 of file atom.py.

Definition at line 277 of file atom.py.

Definition at line 278 of file atom.py.

Definition at line 274 of file atom.py.

Definition at line 275 of file atom.py.

Definition at line 267 of file atom.py.

Definition at line 268 of file atom.py.

Definition at line 273 of file atom.py.

Definition at line 271 of file atom.py.

Definition at line 280 of file atom.py.


The documentation for this class was generated from the following file: