'See if new_def_data differs from the persisted version. If so, update
the persisted version and return the new id.
:param user_id: request.user'

def update_definition_from_data(self, course_key, definition_locator, new_def_data, user_id):

    def needs_saved():
        for (key, value) in new_def_data.iteritems():
            if ((key not in old_definition['fields']) or (value != old_definition['fields'][key])):
                return True
        for (key, value) in old_definition.get('fields', {}).iteritems():
            if (key not in new_def_data):
                return True
    old_definition = self.get_definition(course_key, definition_locator.definition_id)
    if (old_definition is None):
        raise ItemNotFoundError(definition_locator)
    new_def_data = self._serialize_fields(old_definition['block_type'], new_def_data)
    if needs_saved():
        definition_locator = self._update_definition_from_data(course_key, old_definition, new_def_data, user_id)
        return (definition_locator, True)
    else:
        return (definition_locator, False)
