Revision Support for Django ModelsMotivationThe 'fullhistory' branch has been lying dormant for a few months it seems (at least no commits to the django hosted branch) - so I've recently updated and implemented leftover functionality in a modified version of the branch.
DisclaimersThis code has been tested and should work with django trunk (last tested r5546) and is likely to have some backwards-incompatibility (I haven't tested it) with 0.96 or earlier, though feedback on this issue is welcome. This code will be experiencing some potentially significant functional changes as some leftover features are integrated - this is your fair warning :-D It is undoubtedly imperfect, but it should work in common use cases that are checked by the included tests. The embedded docs should shed light on any differences. The current code also provides for determining the calling user (the django.contrib.auth.models.User who initiated the model change). This method works (tilts head) but is meant more as a placeholder until a better implementation is discussed/implemented. API
Method Name Return Value get_version(obj,rev) Model/None get_version_by_date(obj,date) QuerySet/list() get_history(obj,offset=0) QuerySet/list() set_version(obj,rev) Model/None restore_version(content_type,obj_id,rev) Model/None
Future WorkModelhistory should probably provide some means (if end user-desired) of providing distinct tables for each revisioned object. With regard to (1), we have syncdb hooks and could be autogenerated; however, (1) might be best served when coupled with a distinct subsystem that manages backend-specific logic - i.e., django/ multi-db allowing for a separate archival database, in which case this discussion would require a much broader consensus/design points. Consider implementing delta-only change log entries (full object serialized in first version, deltas only to follow - (space v. execution time (specifically,reverts))
Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.