Author: Alex
Date: 2009-11-23 10:43:06 -0600 (Mon, 23 Nov 2009)
New Revision: 11765

Modified:
   django/branches/soc2009/multidb/django/core/management/commands/dumpdata.py
   django/branches/soc2009/multidb/django/core/management/commands/syncdb.py
   django/branches/soc2009/multidb/django/db/backends/__init__.py
Log:
[soc2009/multidb] Several optimizations and cleanups.  Patch from Russell 
Keith-Magee.

Modified: 
django/branches/soc2009/multidb/django/core/management/commands/dumpdata.py
===================================================================
--- django/branches/soc2009/multidb/django/core/management/commands/dumpdata.py 
2009-11-23 16:42:56 UTC (rev 11764)
+++ django/branches/soc2009/multidb/django/core/management/commands/dumpdata.py 
2009-11-23 16:43:06 UTC (rev 11765)
@@ -31,10 +31,10 @@
         exclude = options.get('exclude',[])
         show_traceback = options.get('traceback', False)
 
-        excluded_apps = [get_app(app_label) for app_label in exclude]
+        excluded_apps = set(get_app(app_label) for app_label in exclude)
 
         if len(app_labels) == 0:
-            app_list = SortedDict([(app, None) for app in get_apps() if app 
not in excluded_apps])
+            app_list = SortedDict((app, None) for app in get_apps() if app not 
in excluded_apps)
         else:
             app_list = SortedDict()
             for label in app_labels:

Modified: 
django/branches/soc2009/multidb/django/core/management/commands/syncdb.py
===================================================================
--- django/branches/soc2009/multidb/django/core/management/commands/syncdb.py   
2009-11-23 16:42:56 UTC (rev 11764)
+++ django/branches/soc2009/multidb/django/core/management/commands/syncdb.py   
2009-11-23 16:43:06 UTC (rev 11765)
@@ -59,11 +59,11 @@
         created_models = set()
         pending_references = {}
 
-        excluded_apps = [models.get_app(app_label) for app_label in exclude]
-        app_list = [app for app in models.get_apps() if app not in 
excluded_apps]
+        excluded_apps = set(models.get_app(app_label) for app_label in exclude)
+        included_apps = set(app for app in models.get_apps() if app not in 
excluded_apps)
 
         # Create the tables for each model
-        for app in app_list:
+        for app in included_apps:
             app_name = app.__name__.split('.')[-2]
             model_list = models.get_models(app, include_auto_created=True)
             for model in model_list:
@@ -101,7 +101,7 @@
 
         # Install custom SQL for the app (but only if this
         # is a model we've just created)
-        for app in app_list:
+        for app in included_apps:
             app_name = app.__name__.split('.')[-2]
             for model in models.get_models(app):
                 if model in created_models:
@@ -126,7 +126,7 @@
                             print "No custom SQL for %s.%s model" % (app_name, 
model._meta.object_name)
 
         # Install SQL indicies for all newly created models
-        for app in app_list:
+        for app in included_apps:
             app_name = app.__name__.split('.')[-2]
             for model in models.get_models(app):
                 if model in created_models:

Modified: django/branches/soc2009/multidb/django/db/backends/__init__.py
===================================================================
--- django/branches/soc2009/multidb/django/db/backends/__init__.py      
2009-11-23 16:42:56 UTC (rev 11764)
+++ django/branches/soc2009/multidb/django/db/backends/__init__.py      
2009-11-23 16:43:06 UTC (rev 11765)
@@ -16,6 +16,7 @@
     # Python 2.3 fallback
     from django.utils import _decimal as decimal
 
+from django.db import DEFAULT_DB_ALIAS
 from django.db.backends import util
 from django.utils import datetime_safe
 from django.utils.importlib import import_module
@@ -26,7 +27,7 @@
     """
     ops = None
 
-    def __init__(self, settings_dict, alias='default'):
+    def __init__(self, settings_dict, alias=DEFAULT_DB_ALIAS):
         # `settings_dict` should be a dictionary containing keys such as
         # DATABASE_NAME, DATABASE_USER, etc. It's called `settings_dict`
         # instead of `settings` to disambiguate it from Django settings

--

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=.


Reply via email to