[ANN] django-service-urls 1.0.1

11 views
Skip to first unread message

Raffaele Salmaso

unread,
Dec 23, 2018, 4:44:24 PM12/23/18
to djan...@googlegroups.com
Ho appena rilasciato django-service-urls, un'evoluzione di dj-database-url , e gestisce oltre a DATABASES anche i setting CACHES e EMAIL_BACKEND.

Urls
(accetto PR da ogni repository)

Installazione
$ python3 -m pip install django-service-urls

Aggiungi alla fine del tuo file di setting uno o più handler (nel README c'è un esempio più esteso)

import service_urls
DATABASES = service_urls.db.parse(DATABASES)
CACHES = service_urls.cache.parse(CACHES)
if service_urls.email.validate(EMAIL_BACKEND):
    for k, v in service_urls.email.parse(EMAIL_BACKEND).items():
        setting = 'EMAIL_' + ('BACKEND' if k == 'ENGINE' else k)
        globals()[setting] = v

Uso
Modifica i settings in modo da utilizzare le urlstring

DATABASES = {
    'default': os.environ.get('DATABASE_DEFAULT', 'postgres://myuser:mypasswd@localhost:5432/mydb'),
}
CACHES = {
    'default': os.environ.get('CACHE_DEFAULT', ''memcached://127.0.0.1:11211'),
}
EMAIL_BACKEND = os.environ.get('EMAIL_BACKEND', 'smtp://localhost:25')

--
Reply all
Reply to author
Forward
0 new messages