|
Project Information
Links
|
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. Disclaimers- This 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 Work- Modelhistory 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
<model_log> 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))
|