I’m questioning myself regarding the new peewee’s feature: commit_on_success decorator.
-
How is determined if the function is “success”?
-
If I use this decorator, do I need to call
save()on my altered objects?
From what I tried, I think that #2 is YES, but I just want to be sure as I don’t find a clear answer to those two questions in peewee’s documentation.
I think the decorator you mean is actually called
commit_on_success, and is implemented as a method on theDatabaseclass.The idea is that, suppose you want to transfer some money in a request/response. Here’s a really hokey example:
If an exception is raised ANYWHERE in that function, no money will be transferred and the exception will be raised.
Otherwise, if no exception is raised, the money will be transferred and the response returned.