Use object id as context may not be hashable.

This commit is contained in:
Laurence Rowe 2012-09-28 12:30:52 +01:00
parent 598204639d
commit d99c518c83
1 changed files with 3 additions and 3 deletions

View File

@ -33,10 +33,10 @@ def closest_content(context=None):
def _valid_context(context):
"""Walk up until finding a content item."""
# Avoid loops
# Avoid loops. The object id is used as context may not be hashable
seen = set()
while context is not None and aq_base(context) not in seen:
seen.add(aq_base(context))
while context is not None and id(aq_base(context)) not in seen:
seen.add(id(aq_base(context)))
if (IContentish.providedBy(context)
or IFolderish.providedBy(context)):
return context