Beispiel #1
0
    def update_by_attribute(self, attribute, commit=True):
        """
    updates 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 updated is invalid')

        self.__set_class_by_attribute(attribute)
        value = self.__convert_attr_value_to_value(attribute, False)
        BrokerBase.update(self, value, commit)
Beispiel #2
0
    def update(self, instance, commit=True, validate=True):
        """
    overrides BrokerBase.insert
    """

        errors = not instance.validate()
        if errors:
            raise ValidationException(u'User to be updated is invalid')

        if instance.password != 'EXTERNALAUTH':
            # Don't update if the password is already a hash
            if re.match('^[0-9a-f]{40}$', instance.password) is None:
                if not errors:
                    instance.password = hashSHA1(instance.password,
                                                 instance.username)
        try:
            BrokerBase.update(self, instance, commit, validate=False)
            self.do_commit(commit)
        except sqlalchemy.exc.SQLAlchemyError as error:
            self.session.rollback()
            raise BrokerException(error)
 def update(self, instance, commit=True, validate=True):
     type_ = self.get_by_id(instance.identifier)
     if type_.table_id:
         BrokerBase.update(self, instance, commit)
     else:
         raise IntegrityException('Cannot update the None element')