Skip to content

Commit

Permalink
Cleaned up and clarified some log messages and docstrings.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3892 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Oct 3, 2006
1 parent d886e71 commit b08a8db
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions django/core/management.py
Expand Up @@ -397,7 +397,7 @@ def get_sql_sequence_reset(app):
get_sql_sequence_reset.args = APP_ARGS get_sql_sequence_reset.args = APP_ARGS


def get_sql_indexes(app): def get_sql_indexes(app):
"Returns a list of the CREATE INDEX SQL statements for the given app." "Returns a list of the CREATE INDEX SQL statements for all models in the given app."
from django.db import models from django.db import models
output = [] output = []
for model in models.get_models(app): for model in models.get_models(app):
Expand All @@ -407,7 +407,7 @@ def get_sql_indexes(app):
get_sql_indexes.args = APP_ARGS get_sql_indexes.args = APP_ARGS


def _get_sql_index(model): def _get_sql_index(model):
"Returns the CREATE INDEX SQL statements for a specific model" "Returns the CREATE INDEX SQL statements for a single model"
from django.db import backend from django.db import backend
output = [] output = []


Expand Down Expand Up @@ -463,11 +463,12 @@ def syncdb(verbosity=1, interactive=True):
pending_references = {} pending_references = {}


for app in models.get_apps(): for app in models.get_apps():
app_name = app.__name__.split('.')[-2]
model_list = models.get_models(app) model_list = models.get_models(app)
for model in model_list: for model in model_list:
# Create the model's database table, if it doesn't already exist. # Create the model's database table, if it doesn't already exist.
if verbosity >= 2: if verbosity >= 2:
print "Processing model %s" % model._meta print "Processing %s.%s model" % (app_name, model._meta.object_name)
if model._meta.db_table in table_list: if model._meta.db_table in table_list:
continue continue
sql, references = _get_sql_model_create(model, seen_models) sql, references = _get_sql_model_create(model, seen_models)
Expand All @@ -487,7 +488,7 @@ def syncdb(verbosity=1, interactive=True):
sql = _get_many_to_many_sql_for_model(model) sql = _get_many_to_many_sql_for_model(model)
if sql: if sql:
if verbosity >= 2: if verbosity >= 2:
print "Creating many-to-many tables for %s model" % model.__name__ print "Creating many-to-many tables for %s.%s model" % (app_name, model._meta.object_name)
for statement in sql: for statement in sql:
cursor.execute(statement) cursor.execute(statement)


Expand All @@ -496,8 +497,9 @@ def syncdb(verbosity=1, interactive=True):
# Send the post_syncdb signal, so individual apps can do whatever they need # Send the post_syncdb signal, so individual apps can do whatever they need
# to do at this point. # to do at this point.
for app in models.get_apps(): for app in models.get_apps():
app_name = app.__name__.split('.')[-2]
if verbosity >= 2: if verbosity >= 2:
print "Sending post-syncdb signal for application", app.__name__.split('.')[-2] print "Running post-sync handlers for application", app_name
dispatcher.send(signal=signals.post_syncdb, sender=app, dispatcher.send(signal=signals.post_syncdb, sender=app,
app=app, created_models=created_models, app=app, created_models=created_models,
verbosity=verbosity, interactive=interactive) verbosity=verbosity, interactive=interactive)
Expand All @@ -509,17 +511,17 @@ def syncdb(verbosity=1, interactive=True):
initial_sql = get_sql_initial_data_for_model(model) initial_sql = get_sql_initial_data_for_model(model)
if initial_sql: if initial_sql:
if verbosity >= 1: if verbosity >= 1:
print "Installing initial data for %s model" % model._meta.object_name print "Installing initial data for %s.%s model" % model._meta.object_name
try: try:
for sql in initial_sql: for sql in initial_sql:
cursor.execute(sql) cursor.execute(sql)
except Exception, e: except Exception, e:
sys.stderr.write("Failed to install initial SQL data for %s model: %s" % \ sys.stderr.write("Failed to install initial SQL data for %s.%s model: %s" % \
(model._meta.object_name, e)) (app_name, model._meta.object_name, e))
transaction.rollback_unless_managed() transaction.rollback_unless_managed()
else: else:
transaction.commit_unless_managed() transaction.commit_unless_managed()

syncdb.args = '' syncdb.args = ''


def get_admin_index(app): def get_admin_index(app):
Expand Down

0 comments on commit b08a8db

Please sign in to comment.