From 15cb9d4d45af044cdffe63551604401053201d58 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 28 Mar 2007 21:42:32 +0000 Subject: [PATCH] changed file layout and settings file to support the django multiple-database layout code. django tables now go into the (default) sqlite3 database, while the ILS files are still loaded from the (alternate) evergreen postgress database git-svn-id: svn://svn.open-ils.org/ILS/trunk@7120 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/admin/ils_admin/README | 33 +++-------------- Open-ILS/admin/ils_admin/settings.py | 28 ++++++++++++--- .../ils_admin/setup/ils_data/__init__.py | 0 .../ils_admin/setup/{ => ils_data}/models.py | 35 ++++++++++++------- 4 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 Open-ILS/admin/ils_admin/setup/ils_data/__init__.py rename Open-ILS/admin/ils_admin/setup/{ => ils_data}/models.py (94%) diff --git a/Open-ILS/admin/ils_admin/README b/Open-ILS/admin/ils_admin/README index e8cf014a07..59ccf2c6e1 100644 --- a/Open-ILS/admin/ils_admin/README +++ b/Open-ILS/admin/ils_admin/README @@ -1,38 +1,15 @@ 1. Set up the database params in settings.py -2. Comment out the following item in the INSTALLED_APPS variable in settings.py (around line 80): 'ils_admin.setup', - * If this is not commented out, Django will attempt to create tables for the ILS models, which - could cause the creation of duplicate tables with slightly different names/layouts * -3. Run "python manage.py syncdb". This will install the necessary Django tables in the database -4. Uncomment the line commented out in #2. +2. Run "python manage.py syncdb" from within OpenILS/admin/ils_admin directory. + This will install the necessary Django tables in the database. - To test the base Django app installation, you can run "python manage.py shell" to access the models directly. - Also, see http://www.djangoproject.com/documentation/tutorial1/ +see http://www.djangoproject.com/documentation/ for more. -5. Add an Apache config similar to the one below (requires mod_python): - - - # Protect this sensitive sight - Order deny,allow - Deny from all - Allow from 10.0.0.0/8 - SetHandler mod_python - - # set up the python/django handlers - PythonHandler django.core.handlers.modpython - SetEnv DJANGO_SETTINGS_MODULE ils_admin.settings - PythonPath "['/openils/var/admin/', '/usr/lib/python2.4/site-packages/'] +sys.path" - - # set up some good development settings - PythonAutoReload On - PythonDebug On - - -6. Add a symlink to "media" in your document root (e.g /openils/var/web) to the admin media dir: +3. If you use Apache2/mod_python, create a symlink to "media" in your document root (e.g /openils/var/web) to the admin media dir: e.g. /usr/lib/python2.4/site-packages/django/contrib/admin/media/ This can also be accomplished with an Alias directive in Apache config -7. Start apache +... should we create a default django.db to distribute? diff --git a/Open-ILS/admin/ils_admin/settings.py b/Open-ILS/admin/ils_admin/settings.py index 1cdbba4e92..b9b9bf2aca 100644 --- a/Open-ILS/admin/ils_admin/settings.py +++ b/Open-ILS/admin/ils_admin/settings.py @@ -9,14 +9,31 @@ ADMINS = ( MANAGERS = ADMINS -DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_NAME = '' # Or path to database file if using sqlite3. -DATABASE_SCHEMAS = 'public, permission, actor' # Only used with postgresq to support multiple schemas +DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. +DATABASE_NAME = '/openils/var/data/django.db' # Or path to database file if using sqlite3. +DATABASE_SCHEMAS = '' DATABASE_USER = '' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +""" +2007-03-28: the "django" user in the primary ILS database needs to have +the following schemas set in the default search path: actor, permission, public, config +""" + +OTHER_DATABASES = { + 'ils_data': { + 'DATABASE_ENGINE' : 'postgresql', + 'DATABASE_NAME' : 'evergreen', + 'DATABASE_HOST' : '127.0.0.1', + 'DATABASE_PORT' : '5432', + 'DATABASE_USER' : 'django', + 'DATABASE_PASSWORD' : '', + 'MODELS': ['ils_data'] + }, +} + # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE TIME_ZONE = 'America/New_York' @@ -76,7 +93,8 @@ INSTALLED_APPS = ( 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', - 'django.contrib.admin', - 'ils_admin.setup', + 'django.contrib.admin', + 'ils_admin.setup', + 'ils_admin.setup.ils_data', # load the ILS models ) diff --git a/Open-ILS/admin/ils_admin/setup/ils_data/__init__.py b/Open-ILS/admin/ils_admin/setup/ils_data/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Open-ILS/admin/ils_admin/setup/models.py b/Open-ILS/admin/ils_admin/setup/ils_data/models.py similarity index 94% rename from Open-ILS/admin/ils_admin/setup/models.py rename to Open-ILS/admin/ils_admin/setup/ils_data/models.py index e3032b82bc..3b9b63e6d6 100644 --- a/Open-ILS/admin/ils_admin/setup/models.py +++ b/Open-ILS/admin/ils_admin/setup/ils_data/models.py @@ -2,21 +2,12 @@ from django.db import models from django.db.models import signals from django.dispatch import dispatcher -# Create your models here. - +# ?i18n? INTERVAL_HELP_TEXT = 'examples: "1 hour", "14 days", "3 months", "DD:HH:MM:SS.ms"' -PG_SCHEMAS = "actor, permission, public, config" -# --------------------------------------------------------------------- -# Here we run some SQL to manually set the postgres schema search-paths -# --------------------------------------------------------------------- -def setSearchPath(): - from django.db import connection - cursor = connection.cursor() - cursor.execute("SET search_path TO %s" % PG_SCHEMAS) -dispatcher.connect(setSearchPath, signal=signals.class_prepared) -dispatcher.connect(setSearchPath, signal=signals.pre_init) +#PG_SCHEMAS = "actor, permission, public, config" + class GrpTree(models.Model): @@ -285,3 +276,23 @@ class MetabibField(models.Model): return self.name +# register the alternate DB +""" +settings.OTHER_DATABASES['main_db']['MODELS'] = [ + 'GrpTree', + 'OrgUnitType', + 'OrgUnitSetting', + 'PermList', + 'GrpPermMap', + 'User', + 'UsrPermMap', + 'Card', + 'OrgAddress', + 'OrgUnit', + 'RuleCircDuration', + 'RuleMaxFine', + 'RuleRecurringFine', + 'IdentificationType', + 'RuleAgeHoldProtect' ] +""" + -- 2.43.2