Discussion:
[bottlepy] Charset problem and solution in Bottle text input form field
António Manuel Dias
2016-05-08 11:30:25 UTC
Permalink
Hello.

I'm using Bottle 0.13 in Ubuntu 16.04 with Python 3.5.1 and the code below
was giving me problems if I entered characters with diacritical marks, like
á, é, etc. Those characters were being displayed like á and é. For
example "Cliché" was transformed in "Cliché".

The solution was to comment out the line 148 of bottle.py ("urlunquote =
functools.partial(urlunquote, encoding='latin1')"), after which the problem
disappeared.
--
António Manuel Dias


from bottle import run, route, post, request, redirect
@route('/')
@route('/<testinput>')
return '''<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
<p>{testinput}</p>
<form action="/test" method="post">
Test input: <input name="testinput" type="text" />
<input type="submit" value="Submit" />
</form>
</body>
</html>'''.format(testinput=testinput)
@post('/test')
testinput = request.forms['testinput']
print(testinput)
redirect('/%s' % testinput)
run(host='localhost', port=8080)
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcel Hellkamp
2016-05-08 11:44:27 UTC
Permalink
See the yellow "Note" box here:
http://bottlepy.org/docs/dev/tutorial.html#introducing-formsdict
Post by António Manuel Dias
Hello.
I'm using Bottle 0.13 in Ubuntu 16.04 with Python 3.5.1 and the code
below was giving me problems if I entered characters with diacritical
marks, like á, é, etc. Those characters were being displayed like á
and é. For example "Cliché" was transformed in "Cliché".
The solution was to comment out the line 148 of bottle.py ("urlunquote
= functools.partial(urlunquote, encoding='latin1')"), after which the
problem disappeared.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
António Manuel Dias
2016-05-08 12:42:33 UTC
Permalink
Hello.

Thank you! I had not noticed the warning in the documentation (my bad!).
With attribute access it works as expected.
--
António Manuel Dias
Post by Marcel Hellkamp
http://bottlepy.org/docs/dev/tutorial.html#introducing-formsdict
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...