| Okay, I have a Cocoa model-view-controller application. The controller is very basic, it has a fetchall function to get all the data and to put it in a list. In the interface I can change some stuff. By pressing a button bound to the commit function I'd like to start a thread which calls an objectstore.commit to store changes in the database. Full code: # # TestAppDelegate.py # Test # from Foundation import * from AppKit import * from db_objects import * import threading from PyObjCTools import NibClassBuilder class AppController(NibClassBuilder.AutoBaseClass): orders = [] order_mapper = Order.mapper.options( eagerload('person'), eagerload('orderproducts'), eagerload('orderproducts.product')) def commit_(self): # This does not work! # th = threading.Thread(target=objectsore.commit, name='updating database') # th.start() objectstore.commit() def fetchall_(self): orders = list(self.order_mapper.select(limit=10)) # This is needed in order to use cocoa bindings for order in orders: order.orderproducts_list = order.orderproducts.data self.orders = orders On 29-mrt-2006, at 1:51, Jonathan Ellis wrote: I'm pretty sure that committing in a separate thread will commit objects modified in that thread only, since SA's unit-of-work is thread-local. |
- [Sqlalchemy-users] objectstore.commit() within a thread? Koen Bok
- Re: [Sqlalchemy-users] objectstore.commit() within a t... Jonathan Ellis
- Re: [Sqlalchemy-users] objectstore.commit() within... Koen Bok
- Re: [Sqlalchemy-users] objectstore.commit() within... Koen Bok
- Re: [Sqlalchemy-users] objectstore.commit() wi... Jonathan Ellis
- Re: [Sqlalchemy-users] objectstore.commit(... Koen Bok
- Re: [Sqlalchemy-users] objectstore.co... Jonathan Ellis
- Re: [Sqlalchemy-users] objectstore.commit(... Michael Bayer
- Re: [Sqlalchemy-users] objectstore.co... Michael Bayer

