def _validate_update(self, session, obj, existing_obj):
    'Validates that an update is OK before performing it. (Not applied on insert.)\n        By default, validates that the object already exists, and if an expected semanticVersion ID is provided,\n        that it matches.\n        '
    if (not existing_obj):
        raise NotFound(('%s with id %s does not exist' % (self.model_type.__name__, id)))
    if (self.validate_version_match and (existing_obj.semanticVersion != obj.semanticVersion)):
        raise PreconditionFailed(('Expected semanticVersion was %s; stored semanticVersion was %s' % (obj.semanticVersion, existing_obj.semanticVersion)))
    resource_json = json.loads(obj.resource)
    exist_id = str(obj.questionnaireId)
    new_semantic_version = resource_json['version']
    if self.has_dup_semantic_version(session, exist_id, new_semantic_version):
        raise BadRequest('This semantic version already exist for this questionnaire id.')
    self._validate_model(session, obj)
Validates that an update is OK before performing it. (Not applied on insert.)
By default, validates that the object already exists, and if an expected semanticVersion ID is provided,
that it matches.
def _validate_update(self, session, obj, existing_obj):
    'Validates that an update is OK before performing it. (Not applied on insert.)\n        By default, validates that the object already exists, and if an expected semanticVersion ID is provided,\n        that it matches.\n        '
    if (not existing_obj):
        raise NotFound(('%s with id %s does not exist' % (self.model_type.__name__, id)))
    if (self.validate_version_match and (existing_obj.semanticVersion != obj.semanticVersion)):
        raise PreconditionFailed(('Expected semanticVersion was %s; stored semanticVersion was %s' % (obj.semanticVersion, existing_obj.semanticVersion)))
    resource_json = json.loads(obj.resource)
    exist_id = str(obj.questionnaireId)
    new_semantic_version = resource_json['version']
    if self.has_dup_semantic_version(session, exist_id, new_semantic_version):
        raise BadRequest('This semantic version already exist for this questionnaire id.')
    self._validate_model(session, obj)