Opened 6 years ago

Closed 3 years ago

#14656 closed Bug (fixed)

Atom1Feed should write atom:published element

Reported by: ttencate@… Owned by: Matt Deacalion Stevens
Component: contrib.syndication Version: master
Severity: Normal Keywords:
Cc: Matt Deacalion Stevens Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Atom1Feed currently produces XML like this:

<entry>
  <title>..</title>
  <link href="..." rel="alternate"></link>
  <updated>2010-10-18T00:00:00+02:00</updated>
  <author><name>...</name></author>
  <id>...</id>
  <summary type="html">...</summary>
</entry>

The thing to note here is that the date goes in the atom:updated element, not the atom:published element.

The RFC clearly suggests to me that this is not the intended usage:

   The "atom:updated" element is a Date construct indicating the most
   recent instant in time when an entry or feed was modified in a way
   the publisher considers significant.  Therefore, not all
   modifications necessarily result in a changed atom:updated value.

Whereas:

   The "atom:published" element is a Date construct indicating an
   instant in time associated with an event early in the life cycle of
   the entry.

This is more than just a theoretical problem. Google Reader, for example, does not seem to use the updated element, and uses the date that it first saw the item appear. As a result, it does not order the items properly upon first import of the feed.

The code in Django responsible for this:

django/utils/feedgenerator.py:331

if item['pubdate'] is not None:
    handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('utf-8'))

There appears to be no mention of the published element.

I suggest also writing the published element, because this is the intended usage of that element. The updated element is mandatory, so it should still be written as well.

However, maybe this needs review by someone who knows more about Atom and the peculiarities of various feed readers.

Attachments (1)

14656.patch (2.2 KB) - added by matt@… 5 years ago.
A Git patch for this bug.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by James Addison

Severity: Normal
Type: Bug

comment:3 Changed 6 years ago by Flo Ledermann

Easy pickings: unset

Btw. a hacky workaround is monkeypatching the method:

from django.utils.feedgenerator import Atom1Feed, rfc3339_date


# monkey patch buggy Atom implementation in Django
Atom1Feed._add_item_elements = Atom1Feed.add_item_elements

def atom1feed_add_item_elements_patched(self, handler, item, *args, **kwargs):
    if item['pubdate'] is not None:
        handler.addQuickElement(u"published", rfc3339_date(item['pubdate']).decode('utf-8'))
    # include args, kwargs for future compatibility
    self._add_item_elements(handler, item, *args, **kwargs)

Atom1Feed.add_item_elements = atom1feed_add_item_elements_patched

comment:4 Changed 6 years ago by Flo Ledermann

It turns out that Google Reader is in fact ignoring publication dates in any format and always displays the date when an entry was first read:

http://groups.google.com/group/google-reader-troubleshoot/browse_thread/thread/beba58f69bb364a0

So in fact this bug seems to be rather academic.

Changed 5 years ago by matt@…

Attachment: 14656.patch added

A Git patch for this bug.

comment:5 Changed 5 years ago by Matt Deacalion Stevens

Cc: Matt Deacalion Stevens added
Has patch: set
UI/UX: unset

I came across this last night. I've attached a Git patch, for version 1.3.1.

comment:6 Changed 3 years ago by Tim Graham

Needs tests: set

This needs tests in order to get it committed.

comment:7 Changed 3 years ago by Matt Deacalion Stevens

Completely forgot about this one, I'll add tests this evening.

comment:8 Changed 3 years ago by Matt Deacalion Stevens

Code, tests and a shred of documentation can be found here: https://github.com/django/django/pull/1366

comment:9 Changed 3 years ago by Matt Deacalion Stevens

Needs tests: unset
Version: 1.2master

comment:10 Changed 3 years ago by Matt Deacalion Stevens

Owner: changed from nobody to Matt Deacalion Stevens
Status: newassigned

comment:11 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In a269ea4fe0a9a7195f1bd8bf5d462f48c226d525:

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.

Note: See TracTickets for help on using tickets.
Back to Top