Tested and same behavior in shell, yeah an error would be nice but hard to catch.
try using DBSession.flush() in place of the commit and only commit once at the end of the scheduled method On Tue, May 3, 2011 at 9:51 AM, Paul Kraus <[email protected]> wrote: > In my scheduler i have some code that sets a flag on a database record > then remove its after the process is completed. During imports I > needed a way to have my app not allow some other actions to take > place. So i figure i would just write out a record to the DB that the > other code could test for when running. Seemed pretty straight > forward. If during the import the flag doesn't exist it also creates > it. Since I need to update the status right away i set the flag at the > beginning and do a transaction commit. This works. Then at the end i > set the value to 0 and commit again. It returns no errors but doesn't > update the DB. > > def importOrders(): > > import_flag = > DBSession.query(Flag).filter(Flag.flag_name=='import_flag').first() > if not import_flag: > import_flag = Flag('import_flag') > DBSession.add(import_flag) > > import_flag.flag_value = 1 > transaction.commit() > ... # Do stuff > import_flag.flag_value = 0 > transaction.commit() > > The flag will get created and always gets set to 1 but never gets set > to zero. > > PK > > -- > 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. > > -- Vince Spicer Morcova - The easy way to Social <http://www.morcova.com> -- 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.

