magic-removal: django-admin.py init now installs django.contrib.sessions and django.contrib.sites. Also added init_minimal and changed runtests to use it. Note that init_minimal is not available as a django-admin.py command yet.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1845 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
33451f2172
commit
1091c18c39
|
@ -453,8 +453,30 @@ def get_admin_index(app):
|
||||||
get_admin_index.help_doc = "Prints the admin-index template snippet for the given app name(s)."
|
get_admin_index.help_doc = "Prints the admin-index template snippet for the given app name(s)."
|
||||||
get_admin_index.args = APP_ARGS
|
get_admin_index.args = APP_ARGS
|
||||||
|
|
||||||
|
def init_minimal():
|
||||||
|
"Initializes the database."
|
||||||
|
try:
|
||||||
|
from django.db import backend, connection, models
|
||||||
|
from django.models import auth, core
|
||||||
|
cursor = connection.cursor()
|
||||||
|
for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth):
|
||||||
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
import traceback
|
||||||
|
sys.stderr.write("Error: The database couldn't be initialized.\n")
|
||||||
|
sys.stderr.write('\n'.join(traceback.format_exception(*sys.exc_info())) + "\n")
|
||||||
|
try:
|
||||||
|
connection.rollback()
|
||||||
|
except UnboundLocalError:
|
||||||
|
pass
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
connection.commit()
|
||||||
|
init_minimal.args = ''
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"Initializes the database with auth and core."
|
"Initializes the database with sessions, sites, auth and core."
|
||||||
try:
|
try:
|
||||||
from django.db import backend, connection, models
|
from django.db import backend, connection, models
|
||||||
from django.models import auth, core
|
from django.models import auth, core
|
||||||
|
@ -462,15 +484,15 @@ def init():
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth):
|
for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth):
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
# XXX: commented out for now because it breaks the model tests. Will
|
# Install django.contrib.sessions.
|
||||||
# fix when the command init-minimal is added.
|
sessions_app = models.get_app('sessions')
|
||||||
|
install(sessions_app)
|
||||||
# Install django.contrib.sites and create an example site.
|
# Install django.contrib.sites and create an example site.
|
||||||
#sites_app = models.get_app('sites')
|
sites_app = models.get_app('sites')
|
||||||
#install(sites_app)
|
install(sites_app)
|
||||||
#cursor.execute("INSERT INTO %s (%s, %s) VALUES ('example.com', 'Example site')" % \
|
cursor.execute("INSERT INTO %s (%s, %s) VALUES ('example.com', 'Example site')" % \
|
||||||
# (backend.quote_name(Site._meta.db_table), backend.quote_name('domain'),
|
(backend.quote_name(Site._meta.db_table), backend.quote_name('domain'),
|
||||||
# backend.quote_name('name')))
|
backend.quote_name('name')))
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -117,7 +117,7 @@ class TestRunner:
|
||||||
# Initialize the test database.
|
# Initialize the test database.
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
self.output(1, "Initializing test database")
|
self.output(1, "Initializing test database")
|
||||||
management.init()
|
management.init_minimal()
|
||||||
|
|
||||||
# Run the tests for each test model.
|
# Run the tests for each test model.
|
||||||
self.output(1, "Running app tests")
|
self.output(1, "Running app tests")
|
||||||
|
|
Loading…
Reference in New Issue