The issue here is that Kid wants to work with XML and Unicode.
This throws up an issue that HTML entities are not valid Unicode and
must be represented differently.
The following code from TurboBlog (Florent Aide) addresses this issue:
from htmlentitydefs import name2codepoint
def deEntity(content=u""):
for entity in name2codepoint.keys( ):
if entity in content:
content = content.replace(
"&%s;" % entity,
unichr(name2codepoint[entity])
)
#
#
return content
The coding is such that it should be applied each time the text is
editted by a user; rather than each time it is displayed.
This came up as an issue for me when trying to use TinyMCE and appears
in my article on that subject:
http://sureseam.webfactional.com/tgdocs/
Happy hunting
A
On Jul 5, 5:40 am, buffalob <[EMAIL PROTECTED]> wrote:
> I had asked about this in a way that may have focused on
> FeedController more than it should and didn't get any replies, so I'll
> try wording it a little more generally and see if anyone has ideas for
> me.
>
> When my TG code, which otherwise works fine, processes certain
> instances of external data from the web it occasionally crashes with
> a
> "type error: function takes exactly 5 arguments (1 given)"
>
> I think I've narrowed down the data that is causing it to happen and
> theorize the problem occurs in some behind the scenes unicode
> functionality that TG does in it's Kid processing modules but only
> when a character such as "&#151" is present in the data.
>
> The end of the crash dump message is this:
> ...
> \parser.py", line 227, in _coalesce
> text += to_unicode(value, encoding)
> File "c:\python24\lib\site-packages\kid-0.9.5-py2.4.egg\kid
> \parser.py", line 204, in to_unicode
> return unicode(value, encoding)
> type error: function takes exactly 5 arguments (1 given)
>
> Processing the following snippet of XML seems to cause the crash.
> It's a portion of an RSS news feed, and when I put some debug
> conditional processing to skip over this snippet then the crash does
> not happen. I am guessing that the offending character is the
> "&#151"
> following the word "education".
>
> <item>
> <title>Review finds nutrition education failing (AP)</title>
> <link>http://us.rd.yahoo.com/dailynews/rss/health/*http://
> news.yahoo.com/s/ap/20070704/ap_on_he_me/failing_to_fight_fat</link>
> <guid isPermaLink="false">ap/20070704/failing_to_fight_fat</guid>
> <pubDate>Wed, 04 Jul 2007 21:06:50 GMT</pubDate>
> <description>AP - The federal government will spend more than $1
> billion this year on nutrition education &#151; fresh carrot and
> celery snacks, videos of dancing fruit, hundreds of hours of lively
> lessons about how great you will feel if you eat well.</description>
> </item>
>
> Thanks very much in advance for any ideas about how I can add some
> code to prevent the crash.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---