diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/zope/traversing/api.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/zope/traversing/api.py b/src/zope/traversing/api.py index 69a166e..2b09363 100644 --- a/src/zope/traversing/api.py +++ b/src/zope/traversing/api.py @@ -129,7 +129,16 @@ def getParent(obj): Raises TypeError if the object doesn't have enough context to get the parent. """ - return ILocationInfo(obj).getParent() + + if IRoot.providedBy(obj): + return None + + parent = getattr(obj, '__parent__', None) + if parent is not None: + return parent + + raise TypeError("Not enough context information to get parent", obj) + def getParents(obj): |