Hi Mike, On Tuesday, 25 August 2015 00:56:03 UTC+10, Michael Bayer wrote: > > great, thank you, these issues are both repaired as of > d57e5edbcdf915168c613, the diff for his section is: >
Thanks very much! That works perfectly. By the way, you asked if I had changed *history_meta.py* at all: I added some properties on *Versioned* to allow conditional versioning: --- src/app/server/history_meta_orig.py 2015-08-25 10:21:57.555888454 +1000 +++ src/app/server/history_meta.py 2015-08-25 10:23:08.342461090 +1000 @@ -157,6 +157,28 @@ return mp return map + @property + def version_on_update(self): + try: + return self._version_on_update + except AttributeError: + return True + + @version_on_update.setter + def version_on_update(self, enabled): + self._version_on_update = enabled + + @property + def version_on_delete(self): + try: + return self._version_on_delete + except AttributeError: + return True + + @version_on_delete.setter + def version_on_delete(self, enabled): + self._version_on_delete = enabled + def versioned_objects(iter): for obj in iter: @@ -249,7 +271,8 @@ @event.listens_for(session, 'before_flush') def before_flush(session, flush_context, instances): for obj in versioned_objects(session.dirty): - create_version(obj, session) + if obj.version_on_update: + create_version(obj, session) for obj in versioned_objects(session.deleted): - create_version(obj, session, deleted=True) - + if obj.version_on_delete: + create_version(obj, session, deleted=True) The use case being that I only want to create a new version if the user saving an object is different from the user who last saved it. I also thought about adding an explicit *Versioned.create_version* method, but this suffices for now. Cheers, Alex -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.