Ticket #4224: django_deps.py

File django_deps.py, 1.0 KB (added by Tim Chase <django.ticket@…>, 18 years ago)

A sample settings.py that includes the dependency tracking code

Line 
1APP1 = 'proj.app1'
2APP2 = 'proj.app2'
3APP3 = 'proj.app3'
4APP4 = 'proj.app4'
5APP5 = 'proj.app5'
6APP6 = 'proj.app6'
7APP7 = 'proj.app7'
8APP8 = 'proj.app8'
9APP9 = 'proj.app9'
10
11DEPENDENCIES = {
12 APP2: [APP6, APP4, APP3],
13 APP5: [APP6, APP2],
14 APP6: [APP7, APP9, APP8, APP2],
15 }
16
17SPECIFIED_APPS = [
18 APP1,
19 APP2,
20 ]
21
22def dependency_track(dependencies, specs):
23 results = set()
24 dependencies_to_process = specs
25 while dependencies_to_process:
26 dependency = dependencies_to_process.pop()
27 if dependency not in results:
28 results.add(dependency)
29 if dependency in dependencies:
30 dependencies_to_process.extend(
31 [d for d in dependencies[dependency] if d not in results]
32 )
33 return tuple(results)
34
35INSTALLED_APPS = (
36 'django.contrib.auth',
37 'django.contrib.contenttypes',
38 'django.contrib.sessions',
39 'django.contrib.sites',
40) + dependency_track(DEPENDENCIES, SPECIFIED_APPS)
41
42print INSTALLED_APPS
43
Back to Top