--- a/ztfy/utils/traversing.py Sun Nov 20 12:47:11 2011 +0100
+++ b/ztfy/utils/traversing.py Sun Nov 20 12:47:42 2011 +0100
@@ -37,3 +37,29 @@
return interface(parent)
parent = getattr(parent, '__parent__', None)
return None
+
+
+# copied from fanstatic (which copied it from zope.dottedname !)
+def resolve(name, module=None):
+ name = name.split('.')
+ if not name[0]:
+ if module is None:
+ raise ValueError("relative name without base module")
+ module = module.split('.')
+ name.pop(0)
+ while not name[0]:
+ module.pop()
+ name.pop(0)
+ name = module + name
+
+ used = name.pop(0)
+ found = __import__(used)
+ for n in name:
+ used += '.' + n
+ try:
+ found = getattr(found, n)
+ except AttributeError:
+ __import__(used)
+ found = getattr(found, n)
+
+ return found