Dynamically create new kind with all the same properties of existing model class
I'm trying to 开发者_Python百科create a universal way of versioning data for my models. I'd like to dynamically create a new backup for class SomeModel(db.Model)
with new kind BackupSomeModel
.
Do you have any tips on how to do this in python? Or maybe you have a general idea on how to version data in GAE?
PS: I'm trying to move away from a solution described in here.
The easiest way to do it is like this:
class BackupSomeModel(SomeModel): pass
If you're keeping an audit log, though, storing serialized protocol buffers in a separate kind is probably a better approach. I would suggest having an 'AuditLog' kind, entities of which are child entities of the record they audit, containing a serialized PB of the data after each modification.
精彩评论