First attempt at inter-app dependency tracking
|Reported by:||Tim Chase <django.ticket@…>||Owned by:||nobody|
|Severity:||Keywords:||dependency, INSTALLED_APPS, settings.py|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I used a multi-map scheme to track inter-app dependencies. A single function (dependency_track) walks through a list of desired app names (SPECIFIED_APPS) and looks up the dependencies in the multi-map (DEPENDENCIES). Each app and its dependencies (and their sub-dependencies, and their sub-sub-dependencies, ad infinitum) are added to a set() object which is finally returned as a tuple() that can be appended to the INSTALLED_APPS setting to add all the desired modules. My original post to Django Users:
where Simon G. suggested that I post it as a ticket. He mentioned that inter-module dependency-tracking had been discussed on the Django Developers list previously:
I don't know if this addresses any/all of the issues in that thread. The proposed solution there was some tuple of dict()s where each dict had the same pair of name/module which sounds a lot to me like a multi-map would do the job.
This currently requires that module dependency be tracked in a single file (I use settings.py) rather than having each app track its own dependencies. However, it wouldn't be too hard to extend this scheme to walk through each of the apps listed in the SPECIFIED_APPS and check for a pre-defined property (the dependency multi-map) and then build a master DEPENDENCIES multi-map from that source. I haven't thought hard about which way would be better to do it (tracking in a single file, or sniffing each of the modules for a pre-defined property and building up dependencies that way).
It also doesn't try to import them to verify that the proj.appname is a valid module. But Django will holler if they're not availble when it needs them.
Feel free to use it or ignore it. I'm not sure if "Metasystem" is quite the right component, but it seemed the most fitting.
Change History (3)
Changed 8 years ago by Tim Chase <django.ticket@…>
comment:1 Changed 8 years ago by Simon G. <dev@…>
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed