【问题标题】:Supporting PubSubHubbub with PyRSS2Gen?PyRSS2Gen 支持 PubSubHubbub?
【发布时间】:2010-03-02 03:00:41
【问题描述】:

我正在使用 PyRSS2Gen 生成 RSS 提要,并且我正在尝试支持 PubSubHubbub,但我需要添加破坏 RSS 的链接元素。以下是不需要重写为 Atom 的工作:

<atom:link rel="hub" href="http://example.hub.com" xmlns:atom="http://www.w3.org/2005/Atom">
<atom:link rel="self" href="http://example.com" xmlns:atom="http://www.w3.org/2005/Atom">

我可以在 PyRSS2Gen 中添加任意 XML 吗?我不认为 element_attrs 或 rss_attrs 足以实现这一点,或者是吗? PyRSS2Gen.RSS2() 最多需要 1 个链接元素,那么我该怎么做呢?

谢谢,

金博尔

【问题讨论】:

    标签: python rss websub


    【解决方案1】:

    我查看了 PyRSS2Gen 源代码,看起来您所要做的就是重写 RSS 类的 publish_extensions() 方法。可能是这样的:

    import PyRSS2Gen
    
    class MyRSS2(PyRSS2Gen.RSS2):
        def publish_extensions(self, handler):
            PyRSS2Gen._element(handler, 'atom:link', None, {'element': 'attributes here'})
    

    然后使用MyRSS2 而不是PyRSS2Gen.RSS2。那是未经测试的代码,我建议在将其投入生产之前对其进行检查,眨眼。

    【讨论】:

      猜你喜欢
      • 2011-03-02
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多