Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

avoid ConcurrencyError in CaseVersionResource #26

Merged
merged 1 commit into from

2 participants

@klrmn

No description provided.

@camd camd merged commit 8772543 into mozilla:1.4.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. @klrmn
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 0 deletions.
  1. +18 −0 moztrap/model/library/api.py
View
18 moztrap/model/library/api.py
@@ -225,6 +225,24 @@ def read_create_fields(self):
return ["case", "productversion"]
+ def obj_update(self, bundle, request=None, **kwargs):
+ """Set the modified_by field for the object to the request's user,
+ avoid ConcurrencyError by updating cc_version."""
+ # this try/except logging is more helpful than 500 / 404 errors on the
+ # client side
+ bundle = self.check_read_create(bundle)
+ try:
+ bundle = super(MTResource, self).obj_update(
+ bundle=bundle, request=request, **kwargs)
+ # avoid ConcurrencyError
+ bundle.obj.cc_version = self.model.objects.get(
+ id=bundle.obj.id).cc_version
+ bundle.obj.save(user=request.user)
+ return bundle
+ except Exception: # pragma: no cover
+ logger.exception("error updating %s", bundle) # pragma: no cover
+ raise # pragma: no cover
+
def hydrate_productversion(self, bundle):
"""case.product must match productversion.product on CREATE"""
Something went wrong with that request. Please try again.