Markos Kapes | 28 Feb 2012 19:56
Picon

Re: (no subject)

Here's the result:
	In[21]: Title(booktitle=u'étape', kindID=1)
	Out[21]: Title is: title names are:  [u'publisher', u'isbn', 'kind_id', 'booktitle',
u'release_date', u'edition', u'tag', u'type']  values are: [' ', ' ', 1, '\xc3\xa9tape', None, None,
None, None]
So, yes, there are unicode strings in the names. Oddly enough, the only ones that are unicode are the ones
that are fromTable (booktitle is the only declared UnicodeCol & kindID is a foreign key)
Now, the weird part is that when I add an ascii compatible string, despite the fact that some of the  names are
still unicode, it all works and I get a sqlobject entered in the database:
	In[22]: Title(booktitle=u'tape', kindID=1)
	Out[22]: title [u'publisher', u'isbn', 'kind_id', 'booktitle', u'release_date', u'edition',
u'tag', u'type'] [' ', ' ', 1, 'tape', None, None, None, None]
	<Title 11275L booktitle=u'tape' kindID=1L isbn=u' ' publisher=u' ' releaseDate=None tag=None
edition=None type=None>

Thanks, Oleg,  unicode errors still always manage to confuse the hell out of me...
--Marko

On Mon, 2012-02-28 09:11, Oleg Broytman wrote:
> On Mon, Feb 27, 2012 at 08:20:57PM -0500, Markos Kapes wrote:
> > I"m getting a UnicodeDecodeError and I"m unsure how to fix it...
> > 	/Library/Python/2.7/site-packages/sqlobject/dbconnection.pyc in _insertSQL(self, table,
names, values)
> >     	460         return ("INSERT INTO %s (%s) VALUES (%s)" %
> >     	461                 (table, ', '.join(names),
> >     --> 462                  ', '.join([self.sqlrepr(v) for v in values])))
> >     	463 
> >     	464     def transaction(self):
> > 
> > 	UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 14: ordinal not in range(128)
(Continue reading)

Oleg Broytman | 28 Feb 2012 20:20
X-Face
Favicon
Gravatar

Re: Unicode probs...

On Tue, Feb 28, 2012 at 01:56:50PM -0500, Markos Kapes wrote:
> 	Out[21]: Title is: title names are:  [u'publisher', u'isbn', 'kind_id', 'booktitle',
u'release_date', u'edition', u'tag', u'type']  values are: [' ', ' ', 1, '\xc3\xa9tape', None, None,
None, None]
> So, yes, there are unicode strings in the names.

   To fix that edit sqlobject/mysql/mysqlconnection.py, method
columnsFromSchema; search for assignments

kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
kw['dbName'] = field

   make them strings:

kw['name'] = str(soClass.sqlmeta.style.dbColumnToPythonAttr(field))
kw['dbName'] = str(field)

   test and report if that helps.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
(Continue reading)


Gmane