Changes to allow large, fast exports

svn: r13646
This commit is contained in:
Doug Blank 2009-11-21 14:27:25 +00:00
parent 72cca076c5
commit 281fa65cd7
3 changed files with 42 additions and 24 deletions

View File

@ -61,7 +61,7 @@ ngettext = translator.ngettext
from django.conf import settings
import web.settings as default_settings
try:
settings.configure(default_settings, DEBUG=True)
settings.configure(default_settings)
except RuntimeError:
# already configured; ignore
pass

View File

@ -675,13 +675,31 @@ TABLES = [
("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):
"""
Clear the entries of categories of tables. Category is:
"abstract", "type", "ref", "meta", "primary" and "secondary".
"""
for pair in get_tables(*categories):
pair[1].objects.all().delete()
from django.db import connection, transaction
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):
"""

View File

@ -3,7 +3,7 @@
import const
import os
DEBUG = True
DEBUG = False
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ('127.0.0.1',)
@ -49,7 +49,7 @@ TEMPLATE_DIRS = (
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
# "django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"web.grampsdb.views.context_processor",
@ -66,27 +66,27 @@ INSTALLED_APPS = (
# 'debug_toolbar',
)
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
)
#DEBUG_TOOLBAR_PANELS = (
# 'debug_toolbar.panels.version.VersionDebugPanel',
# 'debug_toolbar.panels.timer.TimerDebugPanel',
# 'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
# 'debug_toolbar.panels.headers.HeaderDebugPanel',
# 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
# 'debug_toolbar.panels.template.TemplateDebugPanel',
# 'debug_toolbar.panels.sql.SQLDebugPanel',
# 'debug_toolbar.panels.signals.SignalDebugPanel',
# 'debug_toolbar.panels.logger.LoggingPanel',
# )
def custom_show_toolbar(request):
return True # Always show toolbar, for example purposes only.
#def custom_show_toolbar(request):
# return True # Always show toolbar, for example purposes only.
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': True,
# 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
# 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
'HIDE_DJANGO_SQL': False,
}
#DEBUG_TOOLBAR_CONFIG = {
# 'INTERCEPT_REDIRECTS': True,
## 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
## 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
# 'HIDE_DJANGO_SQL': False,
# }
# Had to add these to use settings.configure():
DATABASE_OPTIONS = ''