2010-03-02 59 views
2

我正在使用PyRSS2Gen來生成一個RSS源,我試圖支持PubSubHubbub,但我需要添加鏈接元素來打破RSS。下面是應該無需重寫爲Atom工作:支持PubSubHubbub與PyRSS2Gen?

<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個鏈接元素,那麼我該怎麼做?

謝謝

金博爾

回答

0

我看着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。這是未經測試的代碼,我建議在投入生產之前檢查它,眨眼。