Changes to allow large, fast exports
svn: r13646
This commit is contained in:
@@ -61,7 +61,7 @@ ngettext = translator.ngettext
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import web.settings as default_settings
|
import web.settings as default_settings
|
||||||
try:
|
try:
|
||||||
settings.configure(default_settings, DEBUG=True)
|
settings.configure(default_settings)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
# already configured; ignore
|
# already configured; ignore
|
||||||
pass
|
pass
|
||||||
|
@@ -675,13 +675,31 @@ TABLES = [
|
|||||||
("ref", MediaRef)
|
("ref", MediaRef)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def no_style():
|
||||||
|
"""Returns a Django Style object that has no colors."""
|
||||||
|
class dummy(object):
|
||||||
|
def __getattr__(self, attr):
|
||||||
|
return lambda x: x
|
||||||
|
return dummy()
|
||||||
|
|
||||||
def clear_tables(*categories):
|
def clear_tables(*categories):
|
||||||
"""
|
"""
|
||||||
Clear the entries of categories of tables. Category is:
|
Clear the entries of categories of tables. Category is:
|
||||||
"abstract", "type", "ref", "meta", "primary" and "secondary".
|
"abstract", "type", "ref", "meta", "primary" and "secondary".
|
||||||
"""
|
"""
|
||||||
for pair in get_tables(*categories):
|
from django.db import connection, transaction
|
||||||
pair[1].objects.all().delete()
|
cursor = connection.cursor()
|
||||||
|
flush_tables = []
|
||||||
|
for (category, model) in get_tables(*categories):
|
||||||
|
flush_tables.append(model._meta.db_table)
|
||||||
|
# tables = connection.introspection.table_names()
|
||||||
|
# flush_tables = [table for table in tables if not table.endswith("type")]
|
||||||
|
statements = connection.ops.sql_flush(no_style(),
|
||||||
|
flush_tables,
|
||||||
|
connection.introspection.sequence_list())
|
||||||
|
for statement in statements:
|
||||||
|
cursor.execute(statement)
|
||||||
|
transaction.commit_unless_managed()
|
||||||
|
|
||||||
def table_stats(*categories):
|
def table_stats(*categories):
|
||||||
"""
|
"""
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
import const
|
import const
|
||||||
import os
|
import os
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = False
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
|
|
||||||
INTERNAL_IPS = ('127.0.0.1',)
|
INTERNAL_IPS = ('127.0.0.1',)
|
||||||
@@ -49,7 +49,7 @@ TEMPLATE_DIRS = (
|
|||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
"django.core.context_processors.auth",
|
"django.core.context_processors.auth",
|
||||||
"django.core.context_processors.debug",
|
# "django.core.context_processors.debug",
|
||||||
"django.core.context_processors.i18n",
|
"django.core.context_processors.i18n",
|
||||||
"django.core.context_processors.media",
|
"django.core.context_processors.media",
|
||||||
"web.grampsdb.views.context_processor",
|
"web.grampsdb.views.context_processor",
|
||||||
@@ -66,27 +66,27 @@ INSTALLED_APPS = (
|
|||||||
# 'debug_toolbar',
|
# 'debug_toolbar',
|
||||||
)
|
)
|
||||||
|
|
||||||
DEBUG_TOOLBAR_PANELS = (
|
#DEBUG_TOOLBAR_PANELS = (
|
||||||
'debug_toolbar.panels.version.VersionDebugPanel',
|
# 'debug_toolbar.panels.version.VersionDebugPanel',
|
||||||
'debug_toolbar.panels.timer.TimerDebugPanel',
|
# 'debug_toolbar.panels.timer.TimerDebugPanel',
|
||||||
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
|
# 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
|
||||||
'debug_toolbar.panels.headers.HeaderDebugPanel',
|
# 'debug_toolbar.panels.headers.HeaderDebugPanel',
|
||||||
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
|
# 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
|
||||||
'debug_toolbar.panels.template.TemplateDebugPanel',
|
# 'debug_toolbar.panels.template.TemplateDebugPanel',
|
||||||
'debug_toolbar.panels.sql.SQLDebugPanel',
|
# 'debug_toolbar.panels.sql.SQLDebugPanel',
|
||||||
'debug_toolbar.panels.signals.SignalDebugPanel',
|
# 'debug_toolbar.panels.signals.SignalDebugPanel',
|
||||||
'debug_toolbar.panels.logger.LoggingPanel',
|
# 'debug_toolbar.panels.logger.LoggingPanel',
|
||||||
)
|
# )
|
||||||
|
|
||||||
def custom_show_toolbar(request):
|
#def custom_show_toolbar(request):
|
||||||
return True # Always show toolbar, for example purposes only.
|
# return True # Always show toolbar, for example purposes only.
|
||||||
|
|
||||||
DEBUG_TOOLBAR_CONFIG = {
|
#DEBUG_TOOLBAR_CONFIG = {
|
||||||
'INTERCEPT_REDIRECTS': True,
|
# 'INTERCEPT_REDIRECTS': True,
|
||||||
# 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
|
## 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
|
||||||
# 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
|
## 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
|
||||||
'HIDE_DJANGO_SQL': False,
|
# 'HIDE_DJANGO_SQL': False,
|
||||||
}
|
# }
|
||||||
|
|
||||||
# Had to add these to use settings.configure():
|
# Had to add these to use settings.configure():
|
||||||
DATABASE_OPTIONS = ''
|
DATABASE_OPTIONS = ''
|
||||||
|
Reference in New Issue
Block a user