Author: arthurk
Date: 2010-08-15 17:02:04 -0500 (Sun, 15 Aug 2010)
New Revision: 13593

Modified:
   django/branches/soc2010/app-loading/django/core/apps.py
   django/branches/soc2010/app-loading/django/db/models/options.py
Log:
[soc2010/app-loading] use the db_prefix attribute to create database tables

Modified: django/branches/soc2010/app-loading/django/core/apps.py
===================================================================
--- django/branches/soc2010/app-loading/django/core/apps.py     2010-08-15 
18:31:48 UTC (rev 13592)
+++ django/branches/soc2010/app-loading/django/core/apps.py     2010-08-15 
22:02:04 UTC (rev 13593)
@@ -25,6 +25,7 @@
         self.name = name
         self.verbose_name = _(name.title())
         self.verbose_name_plural = _(name.title())
+        self.db_prefix = name
         self.errors = []
         self.models = []
         self.module = None
@@ -201,7 +202,7 @@
         self._populate()
         self.write_lock.acquire()
         try:
-            for app_name in settings.INSTALLED_APPS:
+            for app_name in self.installed_apps:
                 if app_label == app_name.split('.')[-1]:
                     mod = self.load_app(app_name, False)
                     if mod is None:

Modified: django/branches/soc2010/app-loading/django/db/models/options.py
===================================================================
--- django/branches/soc2010/app-loading/django/db/models/options.py     
2010-08-15 18:31:48 UTC (rev 13592)
+++ django/branches/soc2010/app-loading/django/db/models/options.py     
2010-08-15 22:02:04 UTC (rev 13593)
@@ -2,6 +2,7 @@
 from bisect import bisect
 
 from django.conf import settings
+from django.core.apps import cache
 from django.db.models.related import RelatedObject
 from django.db.models.fields.related import ManyToManyRel
 from django.db.models.fields import AutoField, FieldDoesNotExist
@@ -95,9 +96,10 @@
             self.verbose_name_plural = string_concat(self.verbose_name, 's')
         del self.meta
 
-        # If the db_table wasn't provided, use the app_label + module_name.
+        # If the db_table wasn't provided, use the db_prefix + module_name.
         if not self.db_table:
-            self.db_table = "%s_%s" % (self.app_label, self.module_name)
+            app_instance = cache.find_app(self.app_label)
+            self.db_table = "%s_%s" % (app_instance.db_prefix, 
self.module_name)
             self.db_table = truncate_name(self.db_table, 
connection.ops.max_name_length())
 
     def _prepare(self, model):

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