An alternative implementation might be to only queue put_attribute() for Item.update().
/mobile
item.put_attribute('fruits', set(['apple','pear']))
item.add_attribute('fruits', set(['banana']))
item.save()
The attribute update queue is a currently a simple dict and doesn't retain prior updates. My vote would be to either enhance the update queue to handle multiple updates, raise an Exception, or eliminate the queuing altogether.
On Mar 5, 2012, at 4:45 PM, Chris Moyer wrote:
> It's actually relatively simple to implement the __setitem__ and __delitem__ functions, the only complicated bit would be that technically if it's a list it would need to override the return value of a list to handle updating that directly. I'll check in what I have for __setitem__ and __delitem__ once I'm sure it passes all the layer2 tests.
--
Andy Davidoff
disruptek.com
1-877-DISRPTK
On Mar 6, 2012, at 5:15 PM, Chris Moyer wrote:
> I had looked at that problem too. This specific use-case seems pretty straight forward, if you do a put then an add,you'd expect that add to update the values you already put, but if you reversed that:
>
> item.add_attribute('fruits', set(['banana']))
> item.put_attribute('fruits', set(['apple','pear']))
> item.save()
>
> Then what should be done? I'd say this literally means that it should be ['apple', 'pear'], but not include 'banana'.
>
> In your example, however, it should contain all three.
>
> I think that's a relatively straight-forward fix if that sounds like the correct behavior.
--
Andy Davidoff
disruptek.com
1-877-DISRPTK