~ubuntu-branches/ubuntu/oneiric/python-django/oneiric-201108291626

« back to all changes in this revision

Viewing changes to django/contrib/gis/db/backends/spatialite/creation.py

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ożarowski, Chris Lamb, Piotr Ożarowski
  • Date: 2011-05-02 22:23:37 UTC
  • mfrom: (1.1.14 upstream) (4.4.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110502222337-bhlfr6gr1l1cj7dn
Tags: 1.3-2
* Team upload.

[ Chris Lamb ]
* Don't remove "backup~" test file - upstream did ship it; we were just
  removing it with dh_clean.

[ Piotr Ożarowski ]
* Fix builds with non-default Python versions installed
* Bump Standards-Version to 3.9.2 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
from django.conf import settings
 
3
from django.core.cache import get_cache
 
4
from django.core.cache.backends.db import BaseDatabaseCache
3
5
from django.core.exceptions import ImproperlyConfigured
4
6
from django.core.management import call_command
5
7
from django.db.backends.sqlite3.creation import DatabaseCreation
22
24
        self.connection.close()
23
25
 
24
26
        self.connection.settings_dict["NAME"] = test_database_name
25
 
        can_rollback = self._rollback_works()
26
 
        self.connection.settings_dict["SUPPORTS_TRANSACTIONS"] = can_rollback
 
27
        # Confirm the feature set of the test database
 
28
        self.connection.features.confirm()
27
29
        # Need to load the SpatiaLite initialization SQL before running `syncdb`.
28
30
        self.load_spatialite_sql()
29
31
        call_command('syncdb', verbosity=verbosity, interactive=False, database=self.connection.alias)
30
32
 
31
 
        if settings.CACHE_BACKEND.startswith('db://'):
32
 
            from django.core.cache import parse_backend_uri
33
 
            _, cache_name, _ = parse_backend_uri(settings.CACHE_BACKEND)
34
 
            call_command('createcachetable', cache_name)
35
 
 
 
33
        for cache_alias in settings.CACHES:
 
34
            cache = get_cache(cache_alias)
 
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
39
        # Get a cursor (even though we don't need one yet). This has
37
40
        # the side effect of initializing the test database.
38
41
        cursor = self.connection.cursor()