On 2 January 2011 12:17, Alex Kamedov <kame...@gmail.com> wrote: > 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'. > ... > }
What about application order? It's important in some parts of Django, like template loading order. > 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. There is another aspect of backwards-compatibility: there are many 3rd party tools that assume INSTALLED_APPS to be a tuple with application names, so changing it to a dictionary will break them. > 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') > ) Same problem as above, keyword arguments have no order. > 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. Isn't this already done ? You can't assign arbitrary names to applications, but if you use "myproject.auth" instead of "django.contrib.auth", get_app() and get_model() will work as you expected. -- Łukasz Rekucki -- 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.