python - 为什么 Django Atom1Feed 使用原子 :updated instead of atom:published?

标签 python django feed atom-feed

我使用看起来像这样的类在 Django 中制作了一个 Atom 提要:

class AtomFeed(Feed):

    feed_type = feedgenerator.Atom1Feed

    # ...

    def item_pubdate(self, post):
        return datetime.datetime(post.date.year, post.date.month, post.date.day)

项目的结果 XML:

<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>

这里要注意的是日期在 atom:updated 元素中,而不是在 atom:published 元素中。

RFC清楚地向我暗示这不是预期的用途:

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.

鉴于:

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.

这不仅仅是一个理论问题。例如,Google Reader 似乎没有使用 updated 元素,而是使用它第一次看到该项目出现的日期。因此,它在第一次导入 Feed 时没有正确排序项目。

负责此操作的 Django 代码:

django/utils/feedgenerator.py:331

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

似乎没有提到 published 元素。

这是 Django 中的错误吗?我误解了 Atom RFC 吗?我还缺少其他东西吗?

最佳答案

你没有遗漏任何东西。 Atom RFC 是正确的,这是 Django 中的一个已知错误;见this Django bug .

它看起来像是一个相对简单的修复程序,所以请随时进入并修补它! ^_^

关于python - 为什么 Django Atom1Feed 使用原子 :updated instead of atom:published?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4143113/

相关文章:

python - 将 numpy 图像转换为 QPixmap

Python:为什么具有两个参数的未绑定(bind)方法的行为不同于类方法?

jquery - 在 Django 框架中发出 ajax Post 请求时出现 403 Forbidden 错误

从应用程序更改时,django 简单历史记录不起作用

ruby-on-rails - 如何将私有(private)提交与事件提要一起使用?

python - mac 操作系统 zsh : command not found: pip

python - Pandas 根据需要匹配的其他列的值创建新的列 ID

python - 在 django 模型中存储字符数组的最佳方法是什么?

youtube - 如何获取YouTube中不切实际的 clown 的RSS?

php - 插入函数时出现mysql版本错误