How to use the persistent.Persistent._p_changed function in persistent

To help you get started, we’ve selected a few persistent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enkore / borgcube / src / borgcube / core / models.py View on Github external
def __getstate__(self):
        ghost = self._p_jar is not None and self._p_changed is None
        if ghost:
            self._evolve()
        state = super().__getstate__()
        state.setdefault('version', self.version)
        return state

    def _set_changed(self, value):
        ghost = self._p_jar is not None and self._p_changed is None
        if ghost:
            self._evolve()
        persistent.Persistent._p_changed.__set__(self, value)

    _p_changed = property(persistent.Persistent._p_changed.__get__, _set_changed, persistent.Persistent._p_changed.__delete__)

    @property
    def _p_mtime(self):
        ghost = self._p_jar is not None and self._p_changed is None
        if ghost:
            self._evolve()
        return persistent.Persistent._p_mtime.__get__(self)

    def _evolve(self):
        current_version = type(self).version
        needs_evolution = self.version != current_version
        if needs_evolution:
            def evolves(member):
                is_method = inspect.ismethod(member)
                if not is_method:
                    return False
github enkore / borgcube / src / borgcube / core / models.py View on Github external
def _set_changed(self, value):
        ghost = self._p_jar is not None and self._p_changed is None
        if ghost:
            self._evolve()
        persistent.Persistent._p_changed.__set__(self, value)