Hi Christian, I'm working on a project where I use Pyramid together with Cornice to > provide a REST-API. When I do a PUT-request, I would like to return the > updated resource in the Response. But as the COMMIT only happens after > returning the Response and request.dbession.commit() is not allowed in the > default configuration (SQLAlchemy-scaffold - "Transaction must be committed > using the transaction manager"), I'm wondering how I could return the > resource with the latest DB-State after updating it with the PUT-payload. > Using a GET right after a successful PUT is my current solutions, but that > feels like an unclean workaround. > > Is there a way to do this without replacing the whole > transaction-mechanism, which seems complex? >
If I read this correctly this is not complex at all. Run: request.dbsession.flush() And SQLAlchemy will sync all in-memory objects from the database. http://docs.sqlalchemy.org/en/latest/orm/session_api.html?highlight=flush#sqlalchemy.orm.session.Session.flush > > Kind regards, > Christian > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/pylons-discuss/bf41d803-9375-445e-a903-a767d507bab9% > 40googlegroups.com > <https://groups.google.com/d/msgid/pylons-discuss/bf41d803-9375-445e-a903-a767d507bab9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Mikko Ohtamaa http://opensourcehacker.com http://twitter.com/moo9000 -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuom8vaZOMYq_Kd14y8cMGGt3sxD4RD7i4c0Cu2KJTeFw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
