Fixed #14656 -- Added Atom1Feed published element

Some feed aggregators make use of the `published` element as well as
the `updated` element (within the Atom standard -- http://bit.ly/2YySb).

The standard allows for these two elements to be present in the same
entry. `Atom1Feed` had implemented the `updated` element which was
incorrectly taking the date from `pubdate`.
This commit is contained in:
Matt Deacalion Stevens 2013-07-17 20:20:20 +01:00 committed by Tim Graham
parent e1c737b62f
commit a269ea4fe0
11 changed files with 179 additions and 38 deletions

View file

@ -815,6 +815,24 @@ This example illustrates all possible attributes and methods for a
item_pubdate = datetime.datetime(2005, 5, 3) # Hard-coded pubdate.
# ITEM UPDATED -- It's optional to use one of these three. This is a
# hook that specifies how to get the updateddate for a given item.
# In each case, the method/attribute should return a Python
# datetime.datetime object.
def item_updateddate(self, item):
"""
Takes an item, as returned by items(), and returns the item's
updateddate.
"""
def item_updateddate(self):
"""
Returns the updateddated for every item in the feed.
"""
item_updateddate = datetime.datetime(2005, 5, 3) # Hard-coded updateddate.
# ITEM CATEGORIES -- It's optional to use one of these three. This is
# a hook that specifies how to get the list of categories for a given
# item. In each case, the method/attribute should return an iterable
@ -928,16 +946,22 @@ They share this interface:
* ``categories``
* ``item_copyright``
* ``ttl``
* ``updateddate``
Extra keyword arguments will be stored for `custom feed generators`_.
All parameters, if given, should be Unicode objects, except:
* ``pubdate`` should be a Python :class:`~datetime.datetime` object.
* ``updateddate`` should be a Python :class:`~datetime.datetime` object.
* ``enclosure`` should be an instance of
:class:`django.utils.feedgenerator.Enclosure`.
* ``categories`` should be a sequence of Unicode objects.
.. versionadded:: 1.7
The optional ``updateddate`` argument was added.
:meth:`.SyndicationFeed.write`
Outputs the feed in the given encoding to outfile, which is a file-like object.

View file

@ -342,11 +342,15 @@ SyndicationFeed
All parameters should be Unicode objects, except ``categories``, which
should be a sequence of Unicode objects.
.. method:: add_item(title, link, description, [author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, **kwargs])
.. method:: add_item(title, link, description, [author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, updateddate=None, **kwargs])
Adds an item to the feed. All args are expected to be Python ``unicode``
objects except ``pubdate``, which is a ``datetime.datetime`` object, and
``enclosure``, which is an instance of the ``Enclosure`` class.
objects except ``pubdate`` and ``updateddate``, which are ``datetime.datetime``
objects, and ``enclosure``, which is an instance of the ``Enclosure`` class.
.. versionadded:: 1.7
The optional ``updateddate`` argument was added.
.. method:: num_items()
@ -380,8 +384,9 @@ SyndicationFeed
.. method:: latest_post_date()
Returns the latest item's ``pubdate``. If none of them have a
``pubdate``, this returns the current date/time.
Returns the latest ``pubdate`` or ``updateddate`` for all items in the
feed. If no items have either of these attributes this returns the
current date/time.
Enclosure
---------