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?
--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 pylons-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/bf41d803-9375-445e-a903-a767d507bab9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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.