Package: django-vcexport
How it worksThere is an application-level API and a model-level API.Use the model-level API to define export behavior per model class, with
automatic exports on save.Use the application-level API to define export behavior in views (for
example) and explicitly trigger content export from your own code.The model-level APIThe design is inspired by Django’s ModelAdmin and ModelForm aspect-oriented
pattern. The core behaviors are defined in thevcexport.models.Exporterclass, which is analogous to ModelAdmin. Like ModelAdmin and ModelForm, you
will subclass the default base to customize the behavior on a per-model basis.For automatic versioning of models, register them with vcexport:import vcexport
vcexport.register(MyModel)This will connect a post_save signal.You can customize the export behavior on a per-model basis by subclassingvcexport.models.Exporterand telling vcexport to register your model with
the custom Exporter:class MyExporter(vcexport.models.Exporter):
  ...
vcexport.register(MyModel, exporter=MyExporter)By default, models are serialized to django’s XML format, because it
works well withdiffand is generic.You can customize the serialization per model by passing a custom
template path as a class attribute:class MyExporter(Exporter):
    repository_template = 'fleem/document_format.txt'The template will be rendered with two context variables;objectwhich is the model instance that was saved, and a booleancreated:{% if created %}New object!{% endif %}
{{object.title}}
{{object.related_field.pk}}
  ****
Color: {{object.color}}
{{object.description}}This allows alternate use cases to be supported:You want to version a model wholesaleYou have a model which has one or two document-like text fields,
and you want to version those fields only – just don’t write out
any other fields in the serialization template.By default the document dumps of your model instances will be saved in
repository paths that look like/app_name/ModelClassName/instance_pk.You can customize the path:class MyExporter(Exporter):
    def repository_path(self):
        return '/my_custom/path_for/this_model/' + self.object.colorNote that if you do this, you may end up with multiple model instances
that save to the same file path in the repository. This is a feature.The default committing user is undefined. At present you cannot
customize this.The default commit message is uninteresting: “Object {{instance.pk}}
(from ‘{{app_name}}.{{model_name}}’) saved by django-vcexport.”You can customize the commit message with a model method that
takes a booleancreated, and returns a string:class MyExporter(Exporter):
    def repository_commit_message(self, created):
        if created:
            return "User %s committed a new %s" % (
              self.object.user.username, self.object.color)
        return "User %s committed %s" % (self.object.user.username,
                                         self.object.color)The application-level APIYou can also export the content explicitly, for example in your model’ssave()method, in view code, etc, with thevcexport.export_to_repositoryfunction:def my_view(request):
    ...
    object = MyModel.objects.get(...)
    object.morx = request.POST['new_morx']
    object.save()

    import vcexport
    vcexport.export_to_repository(object)The default template, commit message, etc are the same as with the model API.
You can customize them in your own code and pass them toexport_to_repository:def my_view(request):
    ...
    object, created = MyModel.objects.get_or_create(...)
    object.morx = request.POST['new_morx']
    object.save()

    import vcexport
    vcexport.export_to_repository(
               object, created=created,
               repository_template='fleem/morx.html',
               message="Changed the morx",
               repository_path='/fleem/objects/%s' % object.pk)Theexport_to_repositoryfunction will return the Revision of the commit,
or None if there were no changes to commit.A middle groundYou may want both the organizational benefits of grouping your behavioral
definitions into an Exporter, and the flexibility of triggering exports
explicitly in your application code.You can invoke an Exporter instance directly to satisfy this yen:def my_view(request):
    ...
    object, created = MyModel.objects.get_or_create(...)
    object.morx = request.POST['new_morx']
    object.save()

    exporter = MyExporterSubclass(object)

    exporter.export_to_repository(object, created=created)Likevcexport.export_to_repositorythis will return the Revision of
the commit or None if the operation resulted in no committed changes.If you want to do this, you will likely not want to register the same
models for automatic post_save export – but maybe you do!ConfigurationYou must provide one piece of configuration in your settings.py file:VCEXPORT_CHECKOUT_DIR: the absolute path to a local checkout of the
repository that you want to store your data inYou may provide additional settings.py configuration:VCEXPORT_BACKEND: one of ‘svn’ or ‘bzr’To use with Subversion, you must have pysvn installed.To use with Bazaar, you must have bazaar installed.If this setting is not specified, the default is Subversion; however,
Bazaar is really a better backend in a lot of ways (including speed
for synchronous commits) and will likely become the primary supported
backend in the future.You will have to initialize your repository // checkout on your own.CreditsOriginally developed at Columbia University’s Center for New Media
Teaching & Learning <http://ccnmtl.columbia.edu>The source code is available on github <http://github.com/ejucovy/django-vcexport>New in this versionMadeExporterimportable asvcexport.ExporterRemoved ‘hg’ option for VCEXPORT_BACKEND, since sven no longer supports this.Added new ‘bzr’ option for VCEXPORT_BACKEND.History0.5.1 (06-12-09)Brown-bag release; madeexport_to_repositoryfunction available as
public API (vcexport.export_to_repository)0.5 (06-12-09)Split apart distinct APIs for model-level behavior and application-level usage.0.4 (24-11-09)Initial release. This package was previously calledsvndjango. It was
redesigned from the ground up and renameddjango-vcexportto describe
more accurately what it does.