[Moin-user] PATCH - RSS to work
Fujio Nobori
toh at fuji-climb.org
Thu Apr 8 03:27:06 EDT 2004
Hello,
Here is a patch (against moin-1.2--patch-279 from tla) for
RSS feature to work right.
RSS feature right now does not work if (at least for me):
1. rdf:Description element has 'link' attribute
1. there is a page whose title is in utf-8
This patch should solve this issue.
I remember Thomas wrote somewhere that we should use
StringIO instead of cStringIO in action/rss_rc.py. But this
doesn't work for me. Insted, changing a line in
wikixml/util.py solved the issue.
How do you think about this, Thomas?
--
Fujio Nobori il|li
email: toh at fuji-climb.org q|@.@|p
m. ( o ) .m
~~~~~~~~~~~~~
-------------- next part --------------
--- orig/MoinMoin/action/rss_rc.py
+++ mod/MoinMoin/action/rss_rc.py
@@ -10,7 +10,7 @@
from MoinMoin import wikixml, config, wikiutil, util
from MoinMoin.logfile import editlog
from MoinMoin.Page import Page
-import StringIO, re
+import cStringIO, re
from MoinMoin.wikixml.util import RssGenerator
def execute(pagename, request):
@@ -45,7 +45,7 @@
ddiffs = 0
# prepare output
- out = StringIO.StringIO()
+ out = cStringIO.StringIO()
handler = RssGenerator(out)
# get data
--- orig/MoinMoin/wikixml/util.py
+++ mod/MoinMoin/wikixml/util.py
@@ -37,7 +37,7 @@
def simpleNode(self, tag, value, attr={}):
self.startNode(tag, attr)
- if value: self.characters(unicode(value, config.charset))
+ if value: self.characters(value)
self.endNode(tag)
def startDocument(self):
@@ -50,6 +50,32 @@
self.endPrefixMapping(prefix or None)
saxutils.XMLGenerator.endDocument(self)
+ def startElementNS(self, name, qname, attrs):
+ # this code is a bit modified version of python2.3/xml/sax/saxutils.py
+ # i needed this because startElementNS() in saxutils.py
+ # cannot handle attr whose name[0] is None, and action/rss_rc.py
+ # set this to None (ex. name = (None, 'link')).
+ if name[0] is None:
+ # if the name was not namespace-scoped, use the unqualified part
+ name = name[1]
+ else:
+ # else try to restore the original prefix from the namespace
+ name = self._current_context[name[0]] + ":" + name[1]
+ self._out.write('<' + name)
+
+ for pair in self._undeclared_ns_maps:
+ self._out.write(' xmlns:%s="%s"' % pair)
+ self._undeclared_ns_maps = []
+
+ for (name, value) in attrs.items():
+ if name[0] is None:
+ # if the name was not namespace-scoped, use the unqualified part
+ name = name[1]
+ else:
+ name = self._current_context[name[0]] + ":" + name[1]
+ self._out.write(' %s=%s' % (name, saxutils.quoteattr(value)))
+ self._out.write('>')
+
class RssGenerator(XMLGenerator):
default_xmlns = {
More information about the Moin-user
mailing list