I too am using sqlalchemy 0.2 with turbogears.  I've been looking at the 
docs, but I lose my understanding of what's happening with connections 
when going through the connection->engine->session abstractions.

What's a good approach to using sqlalchemy in a threaded environment so 
that I can avoid thread safety issues with connections?  I'd prefer to 
not rely on the database driver's thread safety features.

Randall

Michael Bayer wrote:
> jonathan -
> 
> it all changes for the better in 0.2.   forget about objectstore.begin ().
> 
> check it out at:   http://www.sqlalchemy.org/docs_02/
> 
> 
> On May 11, 2006, at 8:43 PM, Jonathan Vanasco wrote:
> 
>>
>> i'm using sqlalchemy through turbogears
>>
>> turbogears doesn't have all-that-hot support for sqlalchemy yet,  and 
>> I can't stand its user visit/identity system, so i'm  implementing my 
>> own (sorry Kevin)
>>
>> i've come up with the following way to handle what I want to do via  
>> the cherrypy request phases
>>
>>     before_request_body
>>         use sqlalchemy to load a session obj
>>
>>     =snip
>>
>>     on_end_resource
>>         update the session object and commit
>>
>> my problem is that where i snipped things in the middle, turbogears  
>> does some stuff itself, i'm guessing there's a begin/commit or  
>> something in there... and i wind up with this error
>> ===
>>   File "build/bdist.darwin-8.6.0-Power_Macintosh/egg/sqlalchemy/ 
>> mapping/unitofwork.py", line 147, in _validate_obj
>> InvalidRequestError: Detected a mapped object not present in the  
>> current thread's Identity Map: '(<class 'myapp.model.Class'>,  
>> ('62dd49990089f0c3c4e57ff54984e55ec90ffa6e',), None)'.  Use  
>> objectstore.import_instance() to place deserialized instances or  
>> instances from other threads
>> ===
>>
>> would anyone have a suggestion on how i can 'check out' a unit of  
>> work and force it to persist?
>>
>> I tried calling     objectstore.begin() , hoping things would nest  -- 
>> no luck
>>
>> i tried creating explicit sessions using     objectstore.Session --  
>> also no luck
>>
>> this might be impossible, i fear.  but i'm hoping for the best.
>>
>>
>>
>>
>> | - - - - - - - - - - - - - - - - - - - -
>> | RoadSound.com / Indie-Rock.net
>> | Collaborative Online Management And Syndication Tools
>> | - - - - - - - - - - - - - - - - - - - -
>>
>>
>>
>>
>>
>>
>> -------------------------------------------------------
>> Using Tomcat but need to do more? Need to support web services,  
>> security?
>> Get stuff done quickly with pre-integrated technology to make your  
>> job easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
>> Geronimo
>> http://sel.as-us.falkag.net/sel? cmd=lnk&kid=120709&bid=263057&dat=121642
>> _______________________________________________
>> Sqlalchemy-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
> 
> 
> 
> 
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job 
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to