I have a model setup to represent a customer. I have a method on that model that returns a representation of that customer as a dictionary. In my controller i convert that dictionary to json and feed it to a page via json.
On my page i have it setup so that when a field is updated I update that field using ajax. In the controller i get my customer, set the new value an the field and then I want to return from the ajax call a new version of the customer as json. The problem is that the changes haven't been committed to the database and even thought the field has been changed when i call Customer.as_dict and send it back as json its the old values. Not a big deal i have worked around this by doing the update and then doing a request after the update for the json. However it would be nice and "cleaner" to just pass the value back dodging the second request. How can I force the commit? DBSession.flush() doesn't work. transaction.commit() breaks just about everything. For instance if you are using request.identity['user'] in a template you will get errors after the transaction commit. How can I force the update? I could just change the dictionary value to the new value before sending it back but the method that handles these updates in the controller is pretty generic so i would have to add a bunch of code to get the fields set correctly if i manually updated it before the return. -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/kSY-O5I2ykAJ. 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.

