-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollback the transaction on error if ATOMIC_REQUESTS is set. #2887
Conversation
|
||
|
||
class BasicView(APIView): | ||
def get(self, request, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make the tests slightly more obvious if we use post
for this state changing operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
This looks really nice! Made a few inline comments as a starting point. |
return Response(data, status=status.HTTP_404_NOT_FOUND) | ||
|
||
elif isinstance(exc, PermissionDenied): | ||
msg = _('Permission denied.') | ||
data = {'detail': six.text_type(msg)} | ||
|
||
set_rollback() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if it'd make more sense to instead have this behavior once, immediately after the point at which the exception handler is called by the view?
That'd ensure that custom exception handlers don't need to deal with rollbacks explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, but since exception_handler
is hook-able through settings.EXCEPTION_HANDLER
, it allows end-users to control transactional behavior.
Just an idea.
@tomchristie thank you for your feedback. I bring the changes you suggested. I would like to squash the commits, so let me know once you think it will be good to go. |
@tomchristie To reply your question, Which is, I guess, what we want to achieve. |
@ticosax I'm sorry going to push even more work on you. Would it be possible to merge the current master ? |
92d6a39
to
34dc98e
Compare
Conflict has been resolved. |
@xordoquy You plan to merge it for 3.1.3 ? |
No promises but working toward it |
For what it worth I'm using this patch on my production environment with my own |
Actually I'm fine with not supporting this for 1.4 or 1.5. |
@@ -6,7 +6,7 @@ envlist = | |||
{py27,py32,py33,py34}-django{17,18,master} | |||
|
|||
[testenv] | |||
commands = ./runtests.py --fast | |||
commands = ./runtests.py --fast {posargs} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what this is for - won't block me for merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allows positional arguments to be passed from running tox <...>
on the command line. It's a valid change. Not properly part of this PR, but fine all the same. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xordoquy
Possible use case: stop tests execution after the first error encountered for a specific tox environment.
$ tox -e py34-django18 -- -x
here -x
is an argument intended for py.test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure i was just wondering how this related to the pull request
Don't get me wrong i'm fine with it
Looks good to me as well. |
Rollback the transaction on error if ATOMIC_REQUESTS is set.
|
champagne ! |
3.1.3 breaks @transaction.non_atomic_requests at all |
I just realized that this will only rollback the main database. |
well.. I'm a fool... ty |
@Bakirelived you're just human, it happens to all of us. Though you are ahead of most because you took the time to go further and reproduce the issue. |
Good work all, thanks for taking this through to a resolution. |
based on #1787
fixes #2034
I open the pull request for discussion.