remove history-meta for templates, replace with hand-made history table

history-meta's dynamic magic is insufficient for templates, where we
need to be able to refer to the specific history table to take
advantage of sqlalchemy's relationship management (2/3rds of an ORM).
So replace it with a custom made version table.

Had to change the version decorator slightly for this
This commit is contained in:
Leo Hemsted
2016-08-02 16:23:14 +01:00
parent 4e01277318
commit 049514d4b2
8 changed files with 57 additions and 34 deletions

View File

@@ -171,17 +171,13 @@ class Versioned(object):
return history_mapper.class_
def versioned_objects(iter):
for obj in iter:
if hasattr(obj, '__history_mapper__'):
yield obj
def create_history(obj, history_cls=None):
if not history_cls:
history_mapper = obj.__history_mapper__
history_cls = history_mapper.class_
def create_history(obj):
obj_mapper = object_mapper(obj)
history_mapper = obj.__history_mapper__
history_cls = history_mapper.class_
history = history_cls()
obj_mapper = object_mapper(obj)
obj_state = attributes.instance_state(obj)
data = {}