Thanks for the pointers, Jonathan; they helped me learn more of how things work.
However, I'm now even more confused. The problem I'm getting seems to hinge on the fact that I need to grab from my Entity the auto-incrementing primary key Field that is generated from the database. I use this as a publicly-visible identifier. I have tried a whole slew of combinations of stuff, and none of them seems satisfactory. All my server methods use a session.begin() and session.commit()/session.rollback() context around the calls to the model. I'd like to do this for obvious db integrity reasons. 1) I have a set up a session that has transactional=True, autoflush=False as suggested by Jonathan, and poke it back into elixir.session. I create a new instance of my Entity within the transactional context. The transaction completes with a commit() (which does a flush deep down inside it). However my python Entity object still does not contain a value for the auto-incremented id. I have to do _another_ flush for that to appear. This seems wrong. 2) If I create a session with transaction=True, autoflush=True I get database locks which hang until the db layer times out. 3) If I create a session with transaction=False, autoflush=True I also lockups when the session is trying to do an autoflush. Should I use the session from 1) but force a flush() in my constructors? This seems to be a general enough problem that others must have encountered it, and I've never seen anyone implement their model entity constructors with flush() littered everywhere. I forgot to mention that the database I am using is MySQL 5.0. Again, any advice offered will be greatly appreciated. Cheers, Luke -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jonathan LaCour Sent: 04 March 2008 20:56 To: [email protected] Subject: [TurboGears] Re: Sessions with Elixir both in and outside of TurboGears Tunmer, Luke wrote: > What is the best way of changing the session that is made > available to Elixir by default? I've plowed through the > documentation and source and it's not clear to me what the > intended way is. The relevant section of the docs: http://elixir.ematia.de/apidocs/elixir.options.html Read the part under `using_options` regarding `session`. You can specify a session through `using_options`, by creating your own and assigning it to `elixir.session`, or by setting `__session__` at the top of the module containing your entities. I believe that TurboGears implements automatic-transactions by creating its own session, and expecting you to use it. You'll likely want to use this session when using your model from within TurboGears, and creating your own when you are using your model outside of TurboGears. Good luck. -- Jonathan LaCour http://cleverdevil.org --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---

