Fixed #7597 -- Added code to force the re-opening of the cursor connection, just in case a post-syncdb handler closes it. Thanks to keithb for the report and fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7889 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2008-07-11 14:06:59 +00:00
parent 8e0b6bdcd5
commit bbb384366f
1 changed files with 5 additions and 2 deletions

View File

@ -106,6 +106,9 @@ class Command(NoArgsCommand):
# to do at this point. # to do at this point.
emit_post_sync_signal(created_models, verbosity, interactive) emit_post_sync_signal(created_models, verbosity, interactive)
# The connection may have been closed by a syncdb handler.
cursor = connection.cursor()
# Install custom SQL for the app (but only if this # Install custom SQL for the app (but only if this
# is a model we've just created) # is a model we've just created)
for app in models.get_apps(): for app in models.get_apps():
@ -144,7 +147,7 @@ class Command(NoArgsCommand):
for sql in index_sql: for sql in index_sql:
cursor.execute(sql) cursor.execute(sql)
except Exception, e: except Exception, e:
sys.stderr.write("Failed to install index for %s.%s model: %s" % \ sys.stderr.write("Failed to install index for %s.%s model: %s\n" % \
(app_name, model._meta.object_name, e)) (app_name, model._meta.object_name, e))
transaction.rollback_unless_managed() transaction.rollback_unless_managed()
else: else: