Opened 15 years ago
Closed 12 years ago
#14656 closed Bug (fixed)
Atom1Feed should write atom:published element
| Reported by: | 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)
Change History (12)
comment:1 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:3 by , 14 years ago
| Easy pickings: | unset |
|---|
comment:4 by , 14 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.
comment:5 by , 14 years ago
| Cc: | 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:8 by , 12 years ago
Code, tests and a shred of documentation can be found here: https://github.com/django/django/pull/1366
comment:9 by , 12 years ago
| Needs tests: | unset |
|---|---|
| Version: | 1.2 → master |
comment:10 by , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:11 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
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