Opened 13 years ago

Closed 11 years ago

#14656 closed Bug (fixed)

Atom1Feed should write atom:published element

Reported by: ttencate@… Owned by: Matt Deacalion Stevens
Component: contrib.syndication Version: dev
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@… 12 years ago.
A Git patch for this bug.

Download all attachments as: .zip

Change History (12)

comment:1 by Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted

comment:2 by James Addison, 13 years ago

Severity: Normal
Type: Bug

comment:3 by Flo Ledermann, 13 years ago

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 by Flo Ledermann, 13 years ago

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.

by matt@…, 12 years ago

Attachment: 14656.patch added

A Git patch for this bug.

comment:5 by Matt Deacalion Stevens, 12 years ago

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 by Tim Graham, 11 years ago

Needs tests: set

This needs tests in order to get it committed.

comment:7 by Matt Deacalion Stevens, 11 years ago

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

comment:8 by Matt Deacalion Stevens, 11 years ago

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

comment:9 by Matt Deacalion Stevens, 11 years ago

Needs tests: unset
Version: 1.2master

comment:10 by Matt Deacalion Stevens, 11 years ago

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

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

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