Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

avoid ConcurrencyError in CaseVersionResource #26

Merged
merged 1 commit into from over 1 year ago

2 participants

Leah Klearman camd
Leah Klearman
klrmn commented

No description provided.

camd camd merged commit 8772543 into from
camd camd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 21, 2013
Leah Klearman klrmn avoid ConcurrencyError in CaseVersionResource ca28abe
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 18 additions and 0 deletions. Show diff stats Hide diff stats

  1. +18 0 moztrap/model/library/api.py
18 moztrap/model/library/api.py
@@ -225,6 +225,24 @@ def read_create_fields(self):
225 225 return ["case", "productversion"]
226 226
227 227
  228 + def obj_update(self, bundle, request=None, **kwargs):
  229 + """Set the modified_by field for the object to the request's user,
  230 + avoid ConcurrencyError by updating cc_version."""
  231 + # this try/except logging is more helpful than 500 / 404 errors on the
  232 + # client side
  233 + bundle = self.check_read_create(bundle)
  234 + try:
  235 + bundle = super(MTResource, self).obj_update(
  236 + bundle=bundle, request=request, **kwargs)
  237 + # avoid ConcurrencyError
  238 + bundle.obj.cc_version = self.model.objects.get(
  239 + id=bundle.obj.id).cc_version
  240 + bundle.obj.save(user=request.user)
  241 + return bundle
  242 + except Exception: # pragma: no cover
  243 + logger.exception("error updating %s", bundle) # pragma: no cover
  244 + raise # pragma: no cover
  245 +
228 246 def hydrate_productversion(self, bundle):
229 247 """case.product must match productversion.product on CREATE"""
230 248

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.