I think it is best that each application has its own configuration files.

The problem is usually the opposite, how to use a pluggable application
without changing the source code. And that is why usually the application
writes the global settings.

I'm using this snippet of code in order to separate local application
settings with global project settings.

Simone

***

from django.conf import settings as django_settings
class ModuleSettings(object):
    """
    This class is used in the pluggable applications
    in order to separate local application settings
    from global project settings

    So each application can have the own settings in own configuration
    file in the app/settings.py
    >>> SAMPLE_CHOICES = ["1", "b", "c"]

    this class is used in app/__init__py to replace the local settings
module with an object:
    >>> from commons.utils import ModuleSettings
    >>> settings = ModuleSettings('MYAPP', settings)

    in this way the application can read and write the own configuration
from
    the own settings file, but you can always override the application
settings configurations
    by writing in the global project settings the costants with the
application prefix.
    >>> MYAPP_SAMPLE_CHOICES = ["A", "B", "C"]
    """


    def __init__(self, prefix, settings_module):
        self.__prefix = prefix
        self.settings_module = settings_module

        # replace the local settings module with an object,
        # overriding the values writted in the global settings
        for name in dir(settings_module):
            if name == name.upper():
                setattr(self, name,
                        getattr(django_settings, "%s_%s" % ( prefix, name
),
                                getattr(settings_module, name)))

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to