src/risclog/sqlalchemy/cache.py
def _instance_change_handler(self, instance, value, oldvalue, initiator):
        """
        Re-index model instances that were changed
        (to keep the index up-to-date).
        Called by SQLAlchemy's model `set` event which fires when a model
        attribute was changed. For more information,
        see: https://docs.sqlalchemy.org/en/13/orm/events.html
        """  # noqa: E501
        if oldvalue is sqlalchemy.util.symbol('NEVER_SET'):
            return

        model = type(instance)
        changed_attr = initiator.key
        model_indices = self._get_model_indices(model)

        for attribute_key in model_indices.keys():
            if changed_attr not in attribute_key:
                continue

            old_instance_key = self._object_instance_key(
                instance, attribute_key, replace={changed_attr: oldvalue}
            )
            new_instance_key = self._object_instance_key(
                instance, attribute_key, replace={changed_attr: value}
            )

            old_cache = model_indices[attribute_key].get(old_instance_key, [])
            if len(old_cache) > 1:
                old_cache.remove(instance)
            else:
                model_indices[attribute_key].pop(old_instance_key, [])

            cache = model_indices[attribute_key].setdefault(
                new_instance_key, []
            )
            if instance not in cache:
                cache.append(instance)

        Re-index model instances that were changed
        (to keep the index up-to-date).
        Called by SQLAlchemy's model `set` event which fires when a model
        attribute was changed. For more information,
        see: https://docs.sqlalchemy.org/en/13/orm/events.html
        
Re-index model instances that were changed
(to keep the index up-to-date).
Called by SQLAlchemy's model `set` event which fires when a model
attribute was changed.
Re - index model instances that were changed ( to keep the index up - to - date ) . Called by SQLAlchemy ' s model ` set ` event which fires when a model attribute was changed .
def _instance_change_handler(self, instance, value, oldvalue, initiator):
        if oldvalue is sqlalchemy.util.symbol('NEVER_SET'):
            return
        model = type(instance)
        changed_attr = initiator.key
        model_indices = self._get_model_indices(model)
        for attribute_key in model_indices.keys():
            if changed_attr not in attribute_key:
                continue
            old_instance_key = self._object_instance_key(
                instance, attribute_key, replace={changed_attr: oldvalue}
            )
            new_instance_key = self._object_instance_key(
                instance, attribute_key, replace={changed_attr: value}
            )
            old_cache = model_indices[attribute_key].get(old_instance_key, [])
            if len(old_cache) > 1:
                old_cache.remove(instance)
            else:
                model_indices[attribute_key].pop(old_instance_key, [])
            cache = model_indices[attribute_key].setdefault(
                new_instance_key, []
            )
            if instance not in cache:
                cache.append(instance)
def _instance_change_handler ( self , instance , value , oldvalue , initiator ) : if oldvalue is sqlalchemy . util . symbol ( 'NEVER_SET' ) : return model = type ( instance ) changed_attr = initiator . key model_indices = self . _get_model_indices ( model ) for attribute_key in model_indices . keys ( ) : if changed_attr not in attribute_key : continue old_instance_key = self . _object_instance_key ( instance , attribute_key , replace = { changed_attr : oldvalue } ) new_instance_key = self . _object_instance_key ( instance , attribute_key , replace = { changed_attr : value } ) old_cache = model_indices [ attribute_key ] . get ( old_instance_key , [ ] ) if len ( old_cache ) > 1 : old_cache . remove ( instance ) else : model_indices [ attribute_key ] . pop ( old_instance_key , [ ] ) cache = model_indices [ attribute_key ] . setdefault ( new_instance_key , [ ] ) if instance not in cache : cache . append ( instance )
Re-index model instances that were changed
(to keep the index up-to-date).
Re - index model instances that were changed ( to keep the index up - to - date ) .
"""
        Re-index model instances that were changed
        (to keep the index up-to-date).
        Called by SQLAlchemy's model `set` event which fires when a model
        attribute was changed. For more information,
        see: https://docs.sqlalchemy.org/en/13/orm/events.html
        """ # noqa: E501
self
instance
value
oldvalue
initiator