diff options
Diffstat (limited to 'paste/deploy/util.py')
-rw-r--r-- | paste/deploy/util.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/paste/deploy/util.py b/paste/deploy/util.py index c5056b2..02d3fa2 100644 --- a/paste/deploy/util.py +++ b/paste/deploy/util.py @@ -58,3 +58,17 @@ def fix_call(callable, *args, **kw): exc_info = fix_type_error(None, callable, args, kw) reraise(*exc_info) return val + + +def lookup_object(spec): + """ + Looks up a module or object from a some.module:func_name specification. + To just look up a module, omit the colon and everything after it. + """ + parts, target = spec.split(':') if ':' in spec else (spec, None) + module = __import__(parts) + + for part in parts.split('.')[1:] + ([target] if target else []): + module = getattr(module, part) + + return module |