I had a want for some simple dependency tracking in the INSTALLED_APPS of my settings.py, so I cranked out the code below. I don't know if it would help anybody else, but I wanted to be able to specify via the DEPENDENCIES that proj.app2 depended on app3, app4, and app6, and so on. That way, I could change my SPECIFIED_APPS based on my install to only include the relevant apps and have my INSTALLED_APPS update with the proper dependencies as well. It should handle circular references too. Or maybe there's something like this already in Django that I missed? :)
Anyways, if anybody finds it useful, feel free to play with it. -tim # various entries of the items as they would # appear in the INSTALLED_APPS APP1 = 'proj.app1' APP2 = 'proj.app2' APP3 = 'proj.app3' APP4 = 'proj.app4' APP5 = 'proj.app5' APP6 = 'proj.app6' APP7 = 'proj.app7' APP8 = 'proj.app8' APP9 = 'proj.app9' # of the form KEY: [apps that KEY depends on] DEPENDENCIES = { APP2: [APP6, APP4, APP3], APP5: [APP6, APP2], APP6: [APP7, APP9, APP8], } # apps that you actually want in this deployment SPECIFIED_APPS = [ APP1, APP2, ] def dependency_track(dependencies, specs): results = set() dependencys_to_process = specs while dependencys_to_process: dependency = dependencys_to_process.pop() if dependency not in results: results.add(dependency) if dependency in dependencies: dependencys_to_process.extend( [d for d in dependencies[dependency] if d not in results] ) return tuple(results) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', ) + dependency_track(DEPENDENCIES, SPECIFIED_APPS) print INSTALLED_APPS --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---