Author: russellm
Date: 2008-07-11 09:06:59 -0500 (Fri, 11 Jul 2008)
New Revision: 7889

Modified:
   django/trunk/django/core/management/commands/syncdb.py
Log:
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.

Modified: django/trunk/django/core/management/commands/syncdb.py
===================================================================
--- django/trunk/django/core/management/commands/syncdb.py      2008-07-11 
13:18:19 UTC (rev 7888)
+++ django/trunk/django/core/management/commands/syncdb.py      2008-07-11 
14:06:59 UTC (rev 7889)
@@ -105,7 +105,10 @@
         # Send the post_syncdb signal, so individual apps can do whatever they 
need
         # to do at this point.
         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
         # is a model we've just created)
         for app in models.get_apps():
@@ -144,7 +147,7 @@
                             for sql in index_sql:
                                 cursor.execute(sql)
                         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))
                             transaction.rollback_unless_managed()
                         else:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to