Hello web2pyers I have a problem with encoding when I work with MSSQL with codepage other than latin1 or unicode Here is my DB connection
dbsol = DAL <http://127.0.0.1:8000/examples/global/vars/DAL>('mssql://user:password@w2ptkts/SacuraOnline', db_codec = 'cp1251', migrate_enabled = False) I'm successfully read and and view any tables from my DB. But when I try to write to my DB, I see strange behavior, like occuring unwanted (or excessive) encoding. Here is example <https://lh3.googleusercontent.com/-w6QKYcvEBi0/U97_Cf7Px1I/AAAAAAAAA4w/z5M68JgVghg/s1600/Error+Flow.png> Also got an error while saving the profile with Cyrillic letters <https://lh6.googleusercontent.com/-t_UzReeCczo/U98AWxpnJnI/AAAAAAAAA48/NZArBBmMk-s/s1600/2014-08-04+14-08-39+Tkts+-+Google+Chrome.png> I got the following ticket Error ticket for "tkts"Ticket ID 127.0.0.1.2014-08-04.14-39-38.9ab5fa77-867f-4e5d-b1c6-67b8e8e66e76 <type 'exceptions.UnicodeEncodeError'> 'charmap' codec can't encode characters in position 0-5: character maps to <undefined>Версияweb2py™Version 2.9.5-trunk+timestamp.2014.03.29.21.54.41PythonPython 2.7.6: C:\Python27\python.exe (prefix: C:\Python27)Traceback 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. Traceback (most recent call last): File "C:\web2py\gluon\restricted.py", line 220, in restricted exec ccode in environment File "C:/web2py/applications/tkts/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/tkts/controllers/default.py>, line 93, in <module> File "C:\web2py\gluon\globals.py", line 385, in <lambda> self._caller = lambda f: f() File "C:/web2py/applications/tkts/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/tkts/controllers/default.py>, line 55, in user return dict(form=auth()) File "C:\web2py\gluon\tools.py", line 1362, in __call__ return getattr(self, args[0])() File "C:\web2py\gluon\tools.py", line 3112, in profile hideerror=self.settings.hideerror): File "C:\web2py\gluon\sqlhtml.py", line 1610, in accepts self.id_field_name]).update(**fields) File "C:\web2py\gluon\dal.py", line 10553, in update ret = db._adapter.update("%s" % table._tablename,self.query,fields) File "C:\web2py\gluon\dal.py", line 1612, in update sql = self._update(tablename, query, fields) File "C:\web2py\gluon\dal.py", line 1607, in _update for (field, value) in fields]) File "C:\web2py\gluon\dal.py", line 1552, in expand return str(self.represent(expression,field_type)) File "C:\web2py\gluon\dal.py", line 3519, in represent return BaseAdapter.represent(self, obj, fieldtype) File "C:\web2py\gluon\dal.py", line 2061, in represent obj = obj.decode('latin1').encode(self.db_codec) File "C:\Python27\Lib\encodings\cp1251.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-5: character maps to <undefined> Error snapshot [image: help] <http://127.0.0.1:8000/admin/default/ticket/tkts/127.0.0.1.2014-08-04.14-39-38.9ab5fa77-867f-4e5d-b1c6-67b8e8e66e76#> <type 'exceptions.UnicodeEncodeError'>('charmap' codec can't encode characters in position 0-5: character maps to <undefined>) inspect attributes Frames - *File C:\web2py\gluon\restricted.py in restricted at line 220* код аргументы переменные - *File C:\web2py\applications\tkts\controllers\default.py in <module> at line 93* код аргументы переменные - *File C:\web2py\gluon\globals.py in <lambda> at line 385* код аргументы переменные - *File C:\web2py\applications\tkts\controllers\default.py in user at line 55* код аргументы переменные - *File C:\web2py\gluon\tools.py in __call__ at line 1362* код аргументы переменные - *File C:\web2py\gluon\tools.py in profile at line 3112* код аргументы переменные - *File C:\web2py\gluon\sqlhtml.py in accepts at line 1610* код аргументы переменные - *File C:\web2py\gluon\dal.py in update at line 10553* код аргументы переменные - *File C:\web2py\gluon\dal.py in update at line 1612* код аргументы переменные - *File C:\web2py\gluon\dal.py in _update at line 1607* код аргументы переменные - *File C:\web2py\gluon\dal.py in expand at line 1552* код аргументы переменные - *File C:\web2py\gluon\dal.py in represent at line 3519* код аргументы переменные - *File C:\web2py\gluon\dal.py in represent at line 2061* код аргументы переменные - *File C:\Python27\Lib\encodings\cp1251.py in encode at line 12* код аргументы переменные Function argument list (self=<encodings.cp1251.Codec instance>, input=u'\xd0\x97\xd0\x90\xd0\x9e "\xd0\x98\xd0\xbd\xd1...d1\x80\xd0\xb8\xd1\x81\xd1\x82-\xd0\x94\xd0\x92"', errors='strict') Code listing 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_table) Variablesglobal encoding_table<EncodingMap object>inputu'\xd0\x97\xd0\x90 \xd0\x9e "\xd0\x98\xd0\xbd\xd1...d1\x80\xd0\xb8\xd1\x81\xd1\x82-\xd0\x94\xd0\x92"'global codecs<module 'codecs' from 'C:\Python27\Lib\codecs.pyc'>errors'strict' codecs.charmap_encode<built-in function charmap_encode> Please, give me any suggestion (advice) about this problem. My web2py enviroment 2.9.5-trunk+timestamp.2014.03.29.21.54.41 (Running on Rocket 1.2.6, Python 2.7.6) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.