Esempio n. 1
0
    def insert(self, instance, commit=True, validate=True):
        """
    overrides BrokerBase.insert
    """
        errors = False
        if validate:
            errors = not instance.validate()
            if errors:
                raise ValidationException(u'User to be inserted is invalid')

        try:
            BrokerBase.insert(self, instance, commit, validate=False)
            self.do_commit(commit)
        except sqlalchemy.exc.SQLAlchemyError as error:
            self.session.rollback()
            raise BrokerException(error)
Esempio n. 2
0
    def inser_by_attribute(self, attribute, commit=True):
        """
    Inserts one Value instance with the information of the given attribute

    :param attribute: the attribute in context
    :type attribute: Attribute

    :returns : Value
    """
        errors = not attribute.validate()
        if errors:
            raise ValidationException(u'Attribute to be inserted is invalid')

        self.__set_class_by_attribute(attribute)
        value = self.__convert_attr_value_to_value(attribute, True)
        value.identifier = None
        BrokerBase.insert(self, value, commit)