Skip to main content

automatic backup of django model instances to a subversion repository

Project description

svndjango has been renamed django-vcexport

http://pypi.python.org/pypi/django-vcexport

This package provides some basic utilities for backing up django model instances to a Subversion repository. It is very experimental at this point and hasn’t been tested in any meaningful environment.

It does not provide any utilities for restoring live data from backups, though it may one day.

Two distinct use cases are supported: * You want to version a model wholesale * You have a model which has one or two document-like text fields, and you want to version those fields only

To use the former, you should subclass svndjango.models.SubversionedMixin and call its .save method from your own. svndjango.models.SubversionedModel is an example (which you can also just subclass directly and not worry about any of it, but it lacks flexibility) – you probably want to call SubversionedMixin.save only after the “actual” .save to your RDB; this will ensure that you don’t accidentally save a revision that ends up being rolled back in the RDB.

Your model instances will be serialized to JSON and saved in repository paths that look like /module/name/class/name/instance_pk.

To be honest, versioning a model wholesale seems like a pretty bad idea to me, unless you’re very careful about versioning every related model, and unless you’re versioning the model schemas side-by-side with the content. But it’s fun to experiment with at least.

To use the latter, your model should subclass svndjango.models.SVNDoc in the same manner. Text fields to be versioned must be declared explicitly, by using the svndjango.models.SubversionedTextField field instead of the standard TextField.

Your text fields will be saved directly into the repository in repository paths that look like /module/name/class/name/instance_pk/field_name.

You must provide one piece of configuration in your settings.py file:

SVNDJANGO_CHECKOUT_DIR: the absolute path to a local checkout of the repository that you want to store your data in

A second optional setting is supported:

SVNDJANGO_SILENT_FAILURES: if this is set to True, then any exceptions caused by svndjango will be swallowed. This may be useful if you’d rather avoid user errors than preserve a strictly full history of changes.

You will have to initialize your SVN repository and checkout on your own, though these may be automated in future versions. (Not that it’s hard to do anyway)

You must have pysvn installed.

Originally developed at Columbia University’s Center for New Media Teaching & Learning <http://ccnmtl.columbia.edu>

New in version 0.3:

  • Added svndjango.sven.DjangoAutoupdatingSvnAccess class (depends on sven>=0.4) which will deserialize Django model objects out of your committed documents and save them to your Django database after the commit goes through.

    Assumes you will have your Django environment and settings properly installed at checkin-time, and assumes that all checkins should be saved to the Django database.

    If these conditions are met, use as a drop-in replacement for sven.backend.SvnAccess (see that package’s documentation for usage)

History:

0.2 (07-30-2009)

  • Declare sample SubversionedModel as an abstract base class so django won’t create a pointless database table for it.

0.1 (07-24-2009)

Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svndjango-0.3.tar.gz (4.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page