开发者

Supporting PubSubHubbub with PyRSS2Gen?

开发者 https://www.devze.com 2022-12-22 02:14 出处:网络
I\'m using PyRSS2Gen to generate a RSS feed and I\'m trying to support PubSubHubbub, but I need to add link elements that break RSS.Here\'s what should work without requiring a rewrite as Atom:

I'm using PyRSS2Gen to generate a RSS feed and I'm trying to support PubSubHubbub, but I need to add link elements that break RSS. Here's what should work without requiring a rewrite as 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">

Can I add arbitrary XML in PyRSS2Gen somehow? I don't think element_attrs or rss_attrs are enough to accomplish this, or are they? PyRSS2Gen.RSS2() expects at most 1 link element, so how can 开发者_开发问答I do this?

Thank you,

Kimball


I looked at the PyRSS2Gen source code, and it looks like all you have to do is override the RSS class' publish_extensions() method. Something like this perhaps:

import PyRSS2Gen

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

Then use MyRSS2 instead of PyRSS2Gen.RSS2. That's untested code, I recommend checking it before putting it in production, wink.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号