Factor out "get a module-level object from a dotted path" function
|Reported by:||Carl Meyer||Owned by:||Claude Paroz|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
We've got importlib.import_module, but we're missing a higher-level function that would take "x.y.z.foo" (and maybe a fallback default?) and return the actual object "foo" from the "x.y.z" module. Instead we've got the same .rsplit(1) code duplicated everywhere we need to do this.
One implementation we could steal is here: https://github.com/erikrose/django-tidings/blob/master/tidings/utils.py#L144
I was sure there was already a ticket for this, but can't seem to find it, so maybe I was wrong...