Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.72 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Is there a proper way of ensuring only one user at a time makes changes to an object with REST HTTP?
  2. # the Django model
  3.  class Thing(models.Model):
  4.       name = models.CharField(max_length=100)
  5.       description = models.TextField()
  6.  
  7.  # the Tastypie Resource
  8.  class ThingResource(ModelResource):
  9.        class Meta:
  10.            queryset = Thing.objects.all()
  11.        
  12. #1 User 1: Opens app viewing Thing #1 with name = "my name", description = "my description"
  13. #2 User 2: Opens app viewing Thing #1 (same state as User 1)
  14. #3 User 2: Changes description of Thing #1 to "something"
  15. #4 User 1: Changes name of Thing #1 to "some other name"
  16.        
  17. If-Unmodified-Since: <date-noted-from-initial-GET>
  18.        
  19. If-Match: <etag-noted-from-initial-GET>