[mod_python] Problem with html quoted/unquoted

Wouter van Marle wouter at squirrel-systems.com
Tue May 16 23:38:18 EDT 2006


Hi all,

I have a problem with POST requests - loosely related to mod_python but
I don't know a better place to ask.

I have a website run by python/mod_python/apache2, using a MySQL
database (accessed through MySQLdb).

For html compatibility reasons, I store all the search data in the MySQL
database in html-quoted format. The term in question that I ran into is:
"Jubiläumsmodell", stored in the database as "Jubiläumsmodell".

The select in the html source, as presented to the browser, is fine (the
html line is abbreviated for here; it contains many more options):
<select name=model>
	<option value="Jubil&auml;umsmodell 40 Jahre">Jubil&auml;umsmodell 40
Jahre</option>
</select>

It is rendered correctly of course by the browser.
Now when the user clicks go, and the POST is generated, the character is
sent back in what I guess is UTF-8 encoding (I assume it's that, as
that's my default encoding) (again only a snippet):
&model=Jubil%C3%A4umsmodell+40+Jahre

And as you can imagine this messes up the search in the MySQL database,
where I can find the term only if it's html quoted again.

So the end of the whole story, the actual question is now: how do I get
from this utf-8 encoding back to html quoted encoding, for searching in
the database? And no, I'm not going to put the info in the database in
utf-8, that must remain html quoted for many other locations where it
goes wrong otherwise.

Wouter.



More information about the Mod_python mailing list