Hello Arthur, thanks for good work on this branch. I've knew about APP_CLASSES on starting the topic, but I not understood why it was not merged with INSTALLED_APPS. Thank you for explanation. Now I see.
I found some problems with contrib applications and managment commands and can produce patch to fix it. Cheers! On Wed, Jan 5, 2011 at 6:29 PM, Arthur Koziel <art...@arthurkoziel.com>wrote: > Hey Alex, > > thanks for taking the time to review the code. However, we've agreed not to > construct the app instances in the settings.py file as it would require > imports to be used, and stick to the convention of dotted paths. You might > want to read this thread [0], but especially this [1] reply from Jannis > Leidel. > > We also discussed this whole thing at the DjangoCon sprints, which led us > to the current implementation. There are now 2 settings with which apps can > be installed: > > - APP_CLASSES: which is a list of dotted paths pointing to App classes > - INSTALLED_APPS: stays the same, dotted paths to python modules > > Arthur > > [0]: > http://groups.google.com/group/django-developers/browse_thread/thread/4cca2086dd485879/ > [1]: http://groups.google.com/group/django-developers/msg/fd2e3bc0593f4158 > > On Sun, Jan 2, 2011 at 12:17 PM, 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'. >> ... >> } >> >> 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<django-developers%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/django-developers?hl=en. >> > > -- > 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<django-developers%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > -- Alex Kamedov skype: kamedov www: kamedov.ru -- 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.