Python Community Server: Development

A weblog about programming in Python, C#, Java, Perl and C++ - and the occasional comment on PyCS development
new: discuss community servers on the CommunityServerWiki!

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

[ Nov ] [ Jan ]

the locals
also available in XML
Copyright (c) 2002 Phillip Pearson
powered by bzero


Georg Bauer rocks

I didn't pay much attention to this when he did it, but a while back Georg Bauer hacked a workaround into PyCS to let it parse the XML Radio creates when you upstream something with unusual chars in it.

The story here is that all communication between Radio and the community server (in this case, PyCS running on uses XML-RPC. XML-RPC is a way of calling methods on web servers by XML-encoding some method arguments and sending the XML via HTTP, then decoding some XML the server sends back to you (that contains the method response).

The problem is that the XML used by XML-RPC isn't quite the same as normal XML. The XML spec says that an XML doc starting with:

<?xml version="1.0"?>

... is encoded in unicode (UTF-8), however the XML-RPC spec says that everything is encoded as US ASCII (ISO-8859-1, I think). Radio and Frontier rely on this, and send US ASCII chars inside an XML document starting with the aforementioned tag.

Georg's hack looks at the incoming XML and converts that ?xml element into:

<?xml version="1.0" encoding="iso-8859-1"?>

... which PyCS's XML parser (expat) parses very nicely.

The upshot of this is that I can now send my last few days of posts to the noteblog. It looks like the send had silently been failing for a while, but now it goes OK.

This is something to remember when using XML-RPC: always send with US ASCII (to keep Frontier happy), and always put the encoding="iso-8859-1" bit in the ?xml element, to keep strict XML parsers happy. Then everything will work fine.

Time to go figure out if I can get Python's xmlrpclib to do this, so bzero will stay compatible with Frontier and PyCS ...

Comment on this post [ so far]