On Wed, 28 Aug 2013 21:20:01 -0700, Ferrous Cranus wrote: > [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127] > File "/home/nikos/public_html/cgi-bin/metrites.py", line 206, in > <module> > [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127] > cur.execute('''SELECT hits FROM counters WHERE url = %s''', page ) [...] > TypeError: unsupported operand type(s) for %: 'bytes' and 'str'
Oh look, it's exactly the same error you started with. Congratulations, you've made exactly no progress. As I asked you yesterday: And what result does form.getvalue return? What is its type? Is it a list, a tuple, a dict, a bytes object, a float, a str object, something else? Have you worked that out yet? If you can't work it out, you can guess, and then test your guess: page = form.getvalue('page') if isinstance(page, list): raise TypeError('guessed it was a list, it is a list') If your guess is wrong, try another guess. Keep going until you work out what type page is. If you can't write to a data file, you can write to the error log: page = form.getvalue('page') raise TypeError('type of page is %r' % type(page)) Keep going until you find out what type of data the variable 'page' is holding. Now read the error message again: unsupported operand type(s) for %: 'bytes' and 'str' Do you understand what that error means? Here is a hint: start a Python interactive session, and try things for yourself: steve@runes:~$ python3.3 Python 3.3.0rc3 (default, Sep 27 2012, 18:31:58) [GCC 4.4.5] on linux Type "help", "copyright", "credits" or "license" for more information. py> py> 'string%s' % 'string' 'stringstring' py> py> b'bytes%s' % b'bytes' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes' Do you see a pattern yet? What do you think will happen if you run this? b'bytes%s' % 'string' Try it and see for yourself. Now look at the error message you are getting. Is it the same error message? Do you think that perhaps it has the same cause? How do you think you might solve this problem? Hint: if you have a data item that is type A, and you need it to be type B, you need to convert from A to B. -- Steven -- http://mail.python.org/mailman/listinfo/python-list