Whenever the app objects discussion is resuscitated, the following by
yours truly may be of relevance:

http://github.com/mrts/plugit/tree/master

As of now, settings handling is present. The SettingsUpdater class in
plugit/settingshandler.py provides a high-level API for updating
configuration files with Django settings.py format. The Django-
specific use case (the project is not Django-related generally) is as
follows.

---

Suppose the app 'foo' needs to be enabled. During enabling, the app
wants to register it's middleware and add a custom setting, 'FOO =
42'.

$ cat settings.py
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
)

# imagine that user calls ./manage.py enable foo, among other things
the following happens:

$ python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from plugit.settingshandler import SettingsUpdater
>>> updater = SettingsUpdater('settings.py')
>>> new_settings = {'FOO': 42}
>>> append_settings = {'MIDDLEWARE_CLASSES': 'foo.middleware.FooMiddleware',
...         'INSTALLED_APPS': 'foo'}
>>> updater.update(new_settings, append_settings)
>>> updater.save()
True

# and the result:

$ cat settings.py
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'foo.middleware.FooMiddleware',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'foo',
)
FOO = 42

---

Currently it's just a proof of concept and a little foray into lib2to3
capabilities. Without careful dependency handling it's not much
useful.

So, this is one way of handling the app installation and corresponding
settings update problem. Hopefully this demonstrates that settings
updates are feasible and robust and perhaps sparks ideas that are
directly useful in Django context.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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