I've made some progress in this area and wanted to share. My SA
objects use DynamicMetaData, so an engine has to be mapped to them. TG
uses a threadlocal context which provides a default session accessible
via sqlalchemy.objectstore. This is not the objectstore from SA 1.
DynamicMetaData instances are connected to an engine via their connect
method. Since we're in a threadlocal context, each spawned thread has
to make this connection. In my situation I've got three groups of data
objects using three different DynamicMetaData instances and I can use
cherrypy's server.on_start_thread_list to schedule execution of these
connections on a thread's initialization as shown below:
engine = sqlalchemy.create_engine(cns)
def connectKlass(thread_index):
for klass in (Tinwsys, User, Project):
class_mapper(klass).mapped_table.metadata.connect(engine)
cherrypy.server.on_start_thread_list.append(connectKlass)
class PlanReviewController(controllers.RootController,
RESTfulController):
As you see, I put the connection code above my controller. I'll
probably place it above my root controller. I'm currently creating my
own engine, but I'll see if this works with TG's PackageEngine.
Feedback is welcome.
Randall
....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---