2015-02-23 04:29:18 +00:00
|
|
|
"""Django DDP app config."""
|
2015-10-08 00:37:03 +00:00
|
|
|
import warnings
|
2015-02-23 04:29:18 +00:00
|
|
|
|
|
|
|
|
from django.apps import AppConfig
|
2015-03-16 04:03:35 +00:00
|
|
|
from django.conf import settings, ImproperlyConfigured
|
2015-02-23 04:29:18 +00:00
|
|
|
|
2015-05-06 09:40:54 +00:00
|
|
|
from dddp import autodiscover
|
2015-04-08 06:14:22 +00:00
|
|
|
|
|
|
|
|
|
2015-02-23 04:29:18 +00:00
|
|
|
class DjangoDDPConfig(AppConfig):
|
2015-03-04 07:29:07 +00:00
|
|
|
|
|
|
|
|
"""Django app config for django-ddp."""
|
|
|
|
|
|
2015-05-06 09:40:54 +00:00
|
|
|
api = None
|
2015-02-23 04:29:18 +00:00
|
|
|
name = 'dddp'
|
|
|
|
|
verbose_name = 'Django DDP'
|
|
|
|
|
|
|
|
|
|
def ready(self):
|
2015-04-08 06:14:22 +00:00
|
|
|
"""Initialisation for django-ddp (setup lookups and signal handlers)."""
|
2015-03-16 04:03:35 +00:00
|
|
|
if not settings.DATABASES:
|
|
|
|
|
raise ImproperlyConfigured('No databases configured.')
|
|
|
|
|
for (alias, conf) in settings.DATABASES.items():
|
2015-10-08 00:37:03 +00:00
|
|
|
engine = conf['ENGINE']
|
2015-12-21 09:59:08 +00:00
|
|
|
if engine not in [
|
|
|
|
|
'django.db.backends.postgresql',
|
|
|
|
|
'django.db.backends.postgresql_psycopg2',
|
|
|
|
|
]:
|
2015-10-08 00:37:03 +00:00
|
|
|
warnings.warn(
|
|
|
|
|
'Database %r uses unsupported %r engine.' % (
|
|
|
|
|
alias, engine,
|
|
|
|
|
),
|
|
|
|
|
UserWarning,
|
2015-03-16 04:03:35 +00:00
|
|
|
)
|
2015-05-06 09:40:54 +00:00
|
|
|
self.api = autodiscover()
|
|
|
|
|
self.api.ready()
|