This repository has been archived by the owner on Jan 14, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving more code into the new backend structure
git-svn-id: https://django-rcsfield.googlecode.com/svn/trunk@39 d91cc5cc-1343-0410-b1ed-e1360c4e4ba3
- Loading branch information
Showing
4 changed files
with
68 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,33 @@ | ||
''' | ||
""" | ||
this file is used to hook an initial checkout (working copy) | ||
into django's syncdb process | ||
''' | ||
""" | ||
|
||
import os | ||
from django.conf import settings | ||
from django.dispatch import dispatcher | ||
from django.db.models import get_models, signals | ||
from fields import RcsTextField | ||
|
||
|
||
|
||
def initial_checkout(sender, created_models, verbosity): | ||
''' | ||
""" | ||
creates the repository / does the initial checkout | ||
for all fields that are versionized. | ||
called via post_syncdb signal from django. | ||
TODO:currently hardcoded for bzr | ||
''' | ||
from bzrlib import bzrdir, workingtree | ||
""" | ||
from rcsfield.backends import backend | ||
sender_name = sender.__name__.split('.')[-2] | ||
checkout_path = os.path.normpath(settings.BZR_WC_PATH) | ||
for model in created_models: | ||
app_label = model._meta.app_label | ||
for field in model._meta.fields: | ||
if field.__class__ == RcsTextField: | ||
if sender_name == app_label: | ||
if verbosity >= 1: | ||
print "%s found in %s.models.%s" % (RcsTextField.__name__, sender_name, model.__name__) | ||
print "Will create an empty bzr branch in %s" % checkout_path | ||
if not os.path.exists(checkout_path): | ||
os.mkdir(checkout_path) | ||
else: | ||
raise Exception('Directory %s already exists, please change your settings or delete the directory' % checkout_path) | ||
field_path = os.path.normpath(os.path.join(checkout_path, app_label)) | ||
if not os.path.exists(field_path): | ||
os.mkdir(field_path) | ||
wt = bzrdir.BzrDir.create_standalone_workingtree(checkout_path) | ||
wt.add(['%s' % app_label,]) | ||
wt.commit(message="initial directory added") | ||
print "Will run init procedure for %s backend" % backend.__name__ | ||
backend.initial("%s/%s/%s" % (app_label, model.__name__, field.name)) | ||
|
||
dispatcher.connect(initial_checkout, signal=signals.post_syncdb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters