Ticket #15255: 15255.diff
File 15255.diff, 3.3 KB (added by , 14 years ago) |
---|
-
django/db/backends/creation.py
380 380 for cache_alias in settings.CACHES: 381 381 cache = get_cache(cache_alias) 382 382 if isinstance(cache, BaseDatabaseCache): 383 from django.db import router 384 if router.allow_syncdb(self.connection.alias, cache.cache_model_class): 385 call_command('createcachetable', cache._table, database=self.connection.alias) 383 call_command('createcachetable', cache._table, database=self.connection.alias) 386 384 387 385 # Get a cursor (even though we don't need one yet). This has 388 386 # the side effect of initializing the test database. -
django/core/management/commands/createcachetable.py
1 1 from optparse import make_option 2 2 3 3 from django.core.management.base import LabelCommand 4 from django.db import connections, transaction, models, DEFAULT_DB_ALIAS 4 from django.core.cache.backends.db import BaseDatabaseCache 5 from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS 5 6 6 7 class Command(LabelCommand): 7 8 help = "Creates the table needed to use the SQL cache backend." … … 18 19 requires_model_validation = False 19 20 20 21 def handle_label(self, tablename, **options): 21 alias = options.get('database', DEFAULT_DB_ALIAS) 22 connection = connections[alias] 22 db = options.get('database', DEFAULT_DB_ALIAS) 23 cache = BaseDatabaseCache(tablename, {}) 24 if not router.allow_syncdb(db, cache.cache_model_class): 25 return 26 connection = connections[db] 23 27 fields = ( 24 28 # "key" is a reserved word in MySQL, so use "cache_key" instead. 25 29 models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True), … … 50 54 curs.execute("\n".join(full_statement)) 51 55 for statement in index_output: 52 56 curs.execute(statement) 53 transaction.commit_unless_managed(using= alias)57 transaction.commit_unless_managed(using=db) -
django/contrib/gis/db/backends/spatialite/creation.py
33 33 for cache_alias in settings.CACHES: 34 34 cache = get_cache(cache_alias) 35 35 if isinstance(cache, BaseDatabaseCache): 36 from django.db import router 37 if router.allow_syncdb(self.connection.alias, cache.cache_model_class): 38 call_command('createcachetable', cache._table, database=self.connection.alias) 36 call_command('createcachetable', cache._table, database=self.connection.alias) 39 37 # Get a cursor (even though we don't need one yet). This has 40 38 # the side effect of initializing the test database. 41 39 cursor = self.connection.cursor()