On 12/10/2010 15:39, Oleg Broytman wrote:
> On Mon, Oct 11, 2010 at 06:17:02PM +0200, Georges Schutz wrote:
>> import sqlobject as sobj
>>
>> class Person(sobj.SQLObject):
>>       name = sobj.StringCol(default=None)
>>
>> conn = sobj.connectionForURI('sqlite:/:memory:')
>>
>> Person.createTable(ifNotExists=True, connection=conn)
>> Person(name="P. Dummy", connection=conn)
>>
>> p = Person.selectBy(name = "P. Dummy", connection=conn)
> ...
>>     File
>> "C:\Python26\lib\site-packages\sqlobject-0.14.0-py2.6.egg\sqlobject\dbconnection.py",
>> line 850, in getConnection
>>       "No connection has been defined for this thread "
>> AttributeError: No connection has been defined for this thread or process
>
>     Congratulations, you managed to find quite a subtle problem! Sometimes
> validators need additional information from connection - most often
> validators need encoding (charset) to convert between str and unicode. In
> your example there is no per-class connection, and validators don't get a
> connection at all. In many cases it could be fixed - the attached patch is
> for testing and discussing.
>     The problem is rather old but it manifested itself now because in
> version 0.13 I refactored validators' code.
>

I applied the attached patch to my 0.14 version which worked with some 
shift operations. I suppose you did your patch on the head of the trunk.
After patching I tested it on the small example code (OK) and on the 
larger project (at leased on parts of it) and every thing worked as 
usual, no error any more.
--> So for me the patch is OK.


>> conn = sobj.connectionForURI('sqlite:/:memory:')
>>                                        ^^^^^^^^
>> Person.createTable(ifNotExists=True, connection=conn)
>                       ^^^^^^^^^^^^^^^^
>     I seems you prepared memory to be rather persistent! (Just kidding.)

Sorry, for that non necessary part of code. I, simply used code from a 
part of my project where a sqlite file is used and  forgot to remove 
this part.

>
> Oleg.
>
>

Thanks for your rapid reaction. Will this patch automatically be part of 
the next releases or is it necessary to fill a bug report?

Georges Schutz


>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2&  L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
>
>
>
> _______________________________________________
> sqlobject-discuss mailing list
> sqlobject-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss



------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to