Hi all! Happy new year! Sorry for my bad english. On this weekend I reviewed app-loading branch[1] and want to propose some improvements.
Now app-loading branch resolve how to load application, store its meta data and load its models. I plan to extend it to get simple way for replacing the same type applications. This problem is know as Lazy Foreign Key and now can be resolve through settings, but django contrib modules currently is not supported it. I propose more beautiful way to resolve this problem. The main goal of my improvements is adding ability to simple replace one application to another with the same type but another functionality. For example, if you need replace `django.contrib.auth` on your own application you must rewrite all used 3rd-party applications linked with it now. I propose way to resolve this problem and I think It is not hard to implement with saving backward compatibilities. 1. Change INSTALLED_APPS form tuple to dictionary or may be it's better to use something with the same interface as tuple and dictionary INSTALLED_APPS = { 'auth': 'django.contrib.auth', 'comments': 'django.contrib.comments'. ... } For backward compatibility it checks on setting load stage and convert to dictionary if it need. INSTALLED_APPS will be low level API to install applications. I propose install application through `install_applications` function like this: from django.core.apps import install_applications INSTALLED_APPS = install_applications( 'django.contrib.contenttypes', 'django.contrib.sessions', ... auth = 'django.contrib.auth', comments = 'django.contrib.comments' gallery = App(path='my_gallery', db_prefix='new_gallery', verbose_name=u'My new gallery') ) There are args and kwargs passed to `install_applications`. It can be python module names of django applications. Keys of kwargs are system names of the installed applications. This names will be used to get application instance in other applications (see next for more details). For applications passed through args keys will be auto generated. The main benefit is a manage installed applications in project settings module without make changes in this applications. Application loading process will be as listed below: * iterate over INSTALLED_APPS items * if item is string - try to load application definition (`Application`class) from python package defined in this string and create its instance. If application definition is not provided, it will be auto generated. `django.core.apps.App` class will be used for it. * if item is `App` instance, check existence of python package at `path` attribute of `App` instance and `ImproperlyConfigured` exception will be raised if this python package is not installed. 2. Way to organize relations between models of different applications (something like this it already exist in app-loading branch and trunk. I show this only for example and demonstrate syntax) from django.core.apps import get_app, get_model auth = get_app('auth') class MyModel(models.Model): user = models.ForeignKey(auth.models.User) or class MyModel(models.Model): user = models.ForeignKey(get_model('auth.User')) 3. Add new exceptions: `AppIsNotInstalled` (instead of `ImproperlyConfigured`) will be raised if it is try to load not installed applications through `get_app`. [1] http://code.djangoproject.com/wiki/SummerOfCode2010#Apploading Waiting for your comments. Cheers! -- 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.