On Thursday 03 December 2009 01:55:39 steve wrote: > in my tests/__init__.py, i changed the setup_db() function do to this: > > def setup_db(): > """Method used to build a database""" > engine = config['pylons.app_globals'].sa_engine > > contact = model.Contact() > contact.full_name = u"Alice Neville" > contact.given_name = u"Alice" > contact.family_name = u"Neville" > contact.birthday = datetime.date(1984, 4, 29) > model.DBSession.add(contact) > > i've also added the call for setup_db() in the setUp() function in the > same file. (i added the call too make sure it gets called b/c > sometimes it runs but not others depending how you trigger the tests.) > > since i could query it right before self.app.get, i was assuming that > it was set up properly. > > ideally, i would like to get it to work without modifying zope's > transaction stuff b/c i m worried that if i don't do it properly, it > would cause even more problems. (this is my first tg project). > conversely, this zope stuff is driving me nuts b/c i am not sure when > it decides to commit and i couldn't get farmdev's fixture module to > work. so if u have some advice or resource on this subject, please > let me know too. > > really appreciate the help.
Try putting transaction.begin() transaction.commit() around your setup_db-code. Also, you should turn on sqlalchemy-engine-echo, so that you see every SQL-statement being issued. You see then the begin & commit's as well, and if you see BEGIN INSERT ... BEGIN you know something is fishy because the second transaction obbiously can't see the changes of the first. Frankly, I'm pretty annoyed by the way SQLALchemy and zope transactions work. It has given us countless headaches. By now we reached a level of somoothness that is ok, and the needed knowledge has percolated through to all developers. But it still sometimes sucks. Diez -- 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.

