I am playing around with PostgreSQL and web.py and I have noticed that if I have a username and password in a database and given that the password may contain special characters that are members of string.printable, then when I want to print the queried password to the browser through a web.py template, something goes wrong with the character escaping and the password doesn't want to display. Instead the browser offers to download a text file (with no file extension) containing the password.
In my Python file:
class login:
...
def POST(self):
...
cursor.execute("SELECT password FROM tbl WHERE username = %s", (f['username'].value, ))
realpassword = cursor.fetchone()
realpassword = realpassword[0]
...
return realpassword
The password appears correctly in the text file that downloads, but how do I display the password as text on the webpage?