Hacker News new | past | comments | ask | show | jobs | submit login

A fourth way: the django config is a template, with entries like:

settings.py:

    CACHES = {
        'default': { 'BACKEND' : 'django.core.cache.backends.memcached.MemcachedCache',
                     'LOCATION' : [ {% for IP in MEMCACHED_SERVERS %}'{{IP}}:{{MEMCACHED_PORT}}', {% endfor %} ],
                     },
Yes, that's a django template in python code. Upon deployment, my fabfile renders the settings file along with various other config files. This makes sure that {{MEMCACHED_PORT}} doesn't accidentally say one thing in settings.py, and another in memcached.conf.

This also allows me to keep my sitewide settings in a single file or two, namely a module in the fabfile folder.

It feels a little dirty to do things this way (though I can't figure out why), but it's saved me a lot of headaches.




I do something similar with Chef. Chef creates a local_settings.py file that outputs python with the server ips and ports for the various services.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: