Back to index

plone3  3.1.7
BinaryDiff.py
Go to the documentation of this file.
00001 from Globals import InitializeClass
00002 from Products.CMFDiffTool.BaseDiff import BaseDiff, _getValue
00003 
00004 
00005 class BinaryDiff(BaseDiff):
00006     """Simple binary difference"""
00007 
00008     meta_type = "Binary Diff"
00009 
00010     def testChanges(self, ob):
00011         """Test the specified object to determine if the change set will apply without errors"""
00012         value = _getValue(ob, self.field)
00013         if not self.same and value != self.oldValue:
00014             raise ValueError, ("Conflict Error during merge", self.field, value, self.oldValue)
00015         
00016     def applyChanges(self, ob):
00017         """Update the specified object with the difference"""
00018         # Simplistic update
00019         self.testChanges(ob)
00020         if not self.same:
00021             setattr(ob, self.field, self.newValue)
00022         
00023 InitializeClass(BinaryDiff)
00024