Skip to content

Quick and dirty test of a simple Django model versioning scheme

Notifications You must be signed in to change notification settings

cordmata/dirtyversion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dirty Version

I threw this together as a proof of concept about how we can simplify our versioning scheme in the ASU Repository.

This is based on tuple versioning of a [type 2 slowly changing dimension] (http://en.wikipedia.org/wiki/Slowly_changing_dimension#Type_2).

Versioning a model requires only that you subclass versions.models.Versionable. The model will have a custom default manager to provide access to current or historical versions.

If a versioned resource is related to another versioned resource (currently only tested for foreign key relationships) the versions.models.VersionedRelation class is provided as a surrogate for reverse attribute lookup as provided by Django. This ensures that you are dealing with the appropriate versions of the related resources. Hooking this up is a bit awkward, but this is just a POC.

Try it out!

Usage is described in detail in the unit tests. Everything should be set up to run the tests out of the box -- just clone the repo and run:

./manage.py syncdb
./manage.py test versions

About

Quick and dirty test of a simple Django model versioning scheme

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages