diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-07-05 14:16:37 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-07-05 14:16:37 +0000 |
| commit | 89c302cf3f63f35161bdb2c09c849b30f35136e2 (patch) | |
| tree | 7e496af24e31a05866192d1382f80b9b7ecee3ae /django | |
| parent | b37dca1aec3afc88d91ec22030ec6bd5334affc0 (diff) | |
Rolled back r16510, r16513 and r16514 because it wasn't ready.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16515 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backends/spatialite/creation.py | 4 | ||||
| -rw-r--r-- | django/core/management/commands/createcachetable.py | 12 | ||||
| -rw-r--r-- | django/db/backends/creation.py | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/django/contrib/gis/db/backends/spatialite/creation.py b/django/contrib/gis/db/backends/spatialite/creation.py index d299208d79..41baf53e7f 100644 --- a/django/contrib/gis/db/backends/spatialite/creation.py +++ b/django/contrib/gis/db/backends/spatialite/creation.py @@ -33,7 +33,9 @@ class SpatiaLiteCreation(DatabaseCreation): for cache_alias in settings.CACHES: cache = get_cache(cache_alias) if isinstance(cache, BaseDatabaseCache): - call_command('createcachetable', cache._table, database=self.connection.alias) + from django.db import router + if router.allow_syncdb(self.connection.alias, cache.cache_model_class): + call_command('createcachetable', cache._table, database=self.connection.alias) # Get a cursor (even though we don't need one yet). This has # the side effect of initializing the test database. cursor = self.connection.cursor() diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py index e2f17abdc5..90172b6ca3 100644 --- a/django/core/management/commands/createcachetable.py +++ b/django/core/management/commands/createcachetable.py @@ -1,8 +1,7 @@ from optparse import make_option from django.core.management.base import LabelCommand -from django.core.cache.backends.db import BaseDatabaseCache -from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS +from django.db import connections, transaction, models, DEFAULT_DB_ALIAS class Command(LabelCommand): help = "Creates the table needed to use the SQL cache backend." @@ -19,11 +18,8 @@ class Command(LabelCommand): requires_model_validation = False def handle_label(self, tablename, **options): - db = options.get('database', DEFAULT_DB_ALIAS) - cache = BaseDatabaseCache(tablename, {}) - if not router.allow_syncdb(db, cache.cache_model_class): - return - connection = connections[db] + alias = options.get('database', DEFAULT_DB_ALIAS) + connection = connections[alias] fields = ( # "key" is a reserved word in MySQL, so use "cache_key" instead. models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True), @@ -54,4 +50,4 @@ class Command(LabelCommand): curs.execute("\n".join(full_statement)) for statement in index_output: curs.execute(statement) - transaction.commit_unless_managed(using=db) + transaction.commit_unless_managed(using=alias) diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 6170bf6b97..437a4297af 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -261,7 +261,9 @@ class BaseDatabaseCreation(object): for cache_alias in settings.CACHES: cache = get_cache(cache_alias) if isinstance(cache, BaseDatabaseCache): - call_command('createcachetable', cache._table, database=self.connection.alias) + from django.db import router + if router.allow_syncdb(self.connection.alias, cache.cache_model_class): + call_command('createcachetable', cache._table, database=self.connection.alias) # Get a cursor (even though we don't need one yet). This has # the side effect of initializing the test database. |
