Commits

Waldemar Kornewald committed 480f102

support configurations in which GAE is not the default DB

  • Participants
  • Parent commits e92e30c

Comments (0)

Files changed (1)

management/commands/runserver.py

 import os
 import sys
 
+from django.db import connections
+from ...db.base import DatabaseWrapper
 from django.core.management.base import BaseCommand
-from django.db import connection
+from django.core.exceptions import ImproperlyConfigured
 
 
 def start_dev_appserver(argv):
                      '--smtp_port', str(settings.EMAIL_PORT),
                      '--smtp_user', settings.EMAIL_HOST_USER,
                      '--smtp_password', settings.EMAIL_HOST_PASSWORD])
+
     # Pass the application specific datastore location to the server.
-    p = connection._get_paths()
-    if '--datastore_path' not in args:
-        args.extend(['--datastore_path', p[0]])
-    if '--blobstore_path' not in args:
-        args.extend(['--blobstore_path', p[1]])
-    if '--history_path' not in args:
-        args.extend(['--history_path', p[2]])
+    for name in connections:
+        connection = connections[name]
+        if isinstance(connection, DatabaseWrapper):
+            p = connection._get_paths()
+            if '--datastore_path' not in args:
+                args.extend(['--datastore_path', p[0]])
+            if '--blobstore_path' not in args:
+                args.extend(['--blobstore_path', p[1]])
+            if '--history_path' not in args:
+                args.extend(['--history_path', p[2]])
+            break
 
     # Reset logging level to INFO as dev_appserver will spew tons of debug logs
     logging.getLogger().setLevel(logging.INFO)