Browse Source

Adicionada conexão a banco de dados Moodle

producao
Sesostris Vieira 10 years ago
parent
commit
824d12ba35
  1. 22
      moodlerouter.py
  2. 3
      sigi/settings/base.py
  3. 4
      sigi/settings/dev.py

22
moodlerouter.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
class MoodleRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label == 'mdl':
return 'moodle'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == 'mdl':
return 'moodle'
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'mdl' and obj2._meta.app_label == 'mdl':
return True
return None
def allow_migrate(self, db, model):
if model._meta.app_label == 'mdl':
return False
return None

3
sigi/settings/base.py

@ -37,6 +37,9 @@ TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
# Database routers
DATABASE_ROUTERS = ['moodlerouter.MoodleRouter',]
# Application definition
INSTALLED_APPS = (

4
sigi/settings/dev.py

@ -8,6 +8,10 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'sigi.db'),
},
'moodle': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'moodle.db'),
}
}

Loading…
Cancel
Save