def after_create_version_object(self, uow, parent_obj, version_obj):
        session = sa.orm.object_session(parent_obj)
        is_deleted = parent_obj in session.deleted

        for prop in versioned_column_properties(parent_obj):
            if has_changes(parent_obj, prop.key) or is_deleted:
                setattr(version_obj, prop.key + self.column_suffix, True)
    def assign_modified_flag(self, parent_obj, version_obj, attr_name):
        """
        Assigns modified flag for given attribute of given version model object
        based on the modification state of this property in given parent model
        object.

        :param parent_obj:
            Parent object to check the modification state of given attribute
        :param version_obj:
            Version object to assign the modification flag into
        :param attr_name:
            Name of the attribute to check the modification state
        """
        if (
            self.manager.option(
                parent_obj,
                'track_property_modifications'
            ) and
            has_changes(parent_obj, attr_name)
        ):
            setattr(
                version_obj,
                attr_name + self.manager.option(
                    parent_obj,
                    'modified_flag_suffix'
                ),
                True
            )
Exemple #3
0
 def get_callback_args(self, root_obj, callback):
     session = sa.orm.object_session(root_obj)
     objects = getdotattr(root_obj, callback.fullpath,
                          lambda obj: obj not in session.deleted)
     path = str(callback.fullpath)
     if '.' in path or has_changes(root_obj, path):
         return (root_obj, callback.func, objects)
 def after_create_version_object(self, uow, parent_obj, version_obj):
     for prop in versioned_column_properties(parent_obj):
         if has_changes(parent_obj, prop.key):
             setattr(
                 version_obj,
                 prop.key + self.column_suffix,
                 True
             )
Exemple #5
0
def has_changed_search_vector(obj):
    """
    Returns whether or not the search vector columns of given SQLAlchemy
    declarative object have changed.

    :param obj: SQLAlchemy declarative model object
    """
    for vector in search_vectors(obj):
        for column_name in vector.type.columns:
            if has_changes(obj, column_name):
                return True
    return False
def has_changed_search_vector(obj):
    """
    Returns whether or not the search vector columns of given SQLAlchemy
    declarative object have changed.

    :param obj: SQLAlchemy declarative model object
    """
    for vector in search_vectors(obj):
        for column_name in vector.type.columns:
            if has_changes(obj, column_name):
                return True
    return False
Exemple #7
0
 def get_callback_args(self, root_obj, callback):
     session = sa.orm.object_session(root_obj)
     objects = getdotattr(
         root_obj,
         callback.fullpath,
         lambda obj: obj not in session.deleted
     )
     path = str(callback.fullpath)
     if '.' in path or has_changes(root_obj, path):
         return (
             root_obj,
             callback.func,
             objects
         )
Exemple #8
0
def set_modification_date(event):
    """Update ``modification_date`` of the object that triggered the event.

    :param event: event that trigerred this handler.
    :type event: :class:`ObjectUpdate`
    """

    exclude = []

    for e in get_settings()['kotti.modification_date_excludes']:
        if isinstance(event.object, e.class_):
            exclude.append(e.key)

    if has_changes(event.object, exclude=exclude):
        event.object.modification_date = datetime.now()
Exemple #9
0
def set_modification_date(event):
    """Update ``modification_date`` of the object that triggered the event.

    :param event: event that trigerred this handler.
    :type event: :class:`ObjectUpdate`
    """

    exclude = []

    for e in get_settings()['kotti.modification_date_excludes']:
        if isinstance(event.object, e.class_):
            exclude.append(e.key)

    if has_changes(event.object, exclude=exclude):
        event.object.modification_date = datetime.now()
 def after_create_version_object(self, uow, parent_obj, version_obj):
     for prop in versioned_column_properties(parent_obj):
         if has_changes(parent_obj, prop.key):
             setattr(version_obj, prop.key + self.column_suffix, True)