1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

boulder-oracle-sprint: Merged to [4839], part two.

git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4842 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters
2007-03-28 21:30:05 +00:00
parent d2c03a3779
commit 1f3fc7bc9f
28 changed files with 672 additions and 127 deletions

View File

@@ -299,7 +299,7 @@ def get_sql_delete(app):
from django.db.backends.util import truncate_name
introspection = get_introspection_module()
# This should work even if a connecton isn't available
# This should work even if a connection isn't available
try:
cursor = connection.cursor()
except:
@@ -486,7 +486,7 @@ def get_sql_indexes_for_model(model):
unique = f.unique and 'UNIQUE ' or ''
output.append(
style.SQL_KEYWORD('CREATE %sINDEX' % unique) + ' ' + \
truncate_name(style.SQL_TABLE('%s_%s' % (model._meta.db_table, f.column)), backend.get_max_name_length()) + ' ' + \
style.SQL_TABLE(backend.quote_name('%s_%s' % (model._meta.db_table, f.column))) + ' ' + \
style.SQL_KEYWORD('ON') + ' ' + \
style.SQL_TABLE(backend.quote_name(model._meta.db_table)) + ' ' + \
"(%s);" % style.SQL_FIELD(backend.quote_name(f.column))
@@ -546,6 +546,7 @@ def syncdb(verbosity=1, interactive=True):
created_models = set()
pending_references = {}
# Create the tables for each model
for app in models.get_apps():
app_name = app.__name__.split('.')[-2]
model_list = models.get_models(app)
@@ -567,6 +568,11 @@ def syncdb(verbosity=1, interactive=True):
cursor.execute(statement)
table_list.append(table_name_converter(model._meta.db_table))
# Create the m2m tables. This must be done after all tables have been created
# to ensure that all referred tables will exist.
for app in models.get_apps():
app_name = app.__name__.split('.')[-2]
model_list = models.get_models(app)
for model in model_list:
if model in created_models:
sql = _get_many_to_many_sql_for_model(model)
@@ -576,7 +582,7 @@ def syncdb(verbosity=1, interactive=True):
for statement in sql:
cursor.execute(statement)
transaction.commit_unless_managed()
transaction.commit_unless_managed()
# Send the post_syncdb signal, so individual apps can do whatever they need
# to do at this point.
@@ -1383,18 +1389,26 @@ def load_data(fixture_labels, verbosity=1):
app_fixtures = [os.path.join(os.path.dirname(app.__file__),'fixtures') for app in get_apps()]
for fixture_label in fixture_labels:
parts = fixture_label.split('.')
if len(parts) == 1:
fixture_name = fixture_label
formats = serializers.get_serializer_formats()
else:
fixture_name, format = '.'.join(parts[:-1]), parts[-1]
if format in serializers.get_serializer_formats():
formats = [format]
else:
formats = []
if verbosity > 0:
print "Loading '%s' fixtures..." % fixture_label
if formats:
print "Loading '%s' fixtures..." % fixture_name
else:
print "Skipping fixture '%s': %s is not a known serialization format" % (fixture_name, format)
for fixture_dir in app_fixtures + list(settings.FIXTURE_DIRS) + ['']:
if verbosity > 1:
print "Checking %s for fixtures..." % humanize(fixture_dir)
parts = fixture_label.split('.')
if len(parts) == 1:
fixture_name = fixture_label
formats = serializers.get_serializer_formats()
else:
fixture_name, format = '.'.join(parts[:-1]), parts[-1]
formats = [format]
label_found = False
for format in formats: