def diff(firstObj, otherObj, includeMeta=False):
if not isIndexedRedisModel(firstObj): <EOL><INDENT>raise ValueError('<STR_LIT>' %( type(firstObj).__name__ , ) )<EOL><DEDENT>if not isIndexedRedisModel(otherObj): <EOL><INDENT>raise ValueError('<STR_LIT>' %( type(otherObj).__name__ , ) )<EOL><DEDENT>firstObj.validateModel()<EOL>otherObj.validateModel()<EOL>if getattr(firstObj, '<STR_LIT>') != getattr(otherObj, '<STR_LIT>'):<EOL><INDENT>raise ValueError('<STR_LIT>' %( firstObj.__class__, otherObj.__class__) )<EOL><DEDENT>diffFields = {}<EOL>for thisField in firstObj.FIELDS:<EOL><INDENT>thisFieldStr = str(thisField)<EOL>firstVal = object.__getattribute__( firstObj, thisFieldStr )<EOL>otherVal = object.__getattribute__( otherObj, thisFieldStr )<EOL>if firstVal != otherVal:<EOL><INDENT>diffFields[ thisFieldStr ] = ( (firstVal, otherVal) )<EOL><DEDENT><DEDENT>if includeMeta:<EOL><INDENT>firstPk = firstObj.getPk()<EOL>otherPk = otherObj.getPk()<EOL>if firstPk != otherPk:<EOL><INDENT>diffFields['<STR_LIT>'] = ( firstPk, otherPk )<EOL><DEDENT><DEDENT>return diffFields<EOL>
diff - Compare the field values on two IndexedRedisModels.

@param firstObj <IndexedRedisModel instance> - First object (or self)

@param otherObj <IndexedRedisModel instance> - Second object

@param includeMeta <bool> - If meta information (like pk) should be in the diff results.


@return <dict> - Dict of  'field' : ( value_firstObjForField, value_otherObjForField ).

        Keys are names of fields with different values.
        Value is a tuple of ( value_firstObjForField, value_otherObjForField )

Can be called statically, like: IndexedRedisModel.diff ( obj1, obj2 )

  or in reference to an obj   : obj1.diff(obj2)