From cffadbdf140c877d90bcdade714b71caabef2958 Mon Sep 17 00:00:00 2001 From: helmutm Date: Wed, 15 Sep 2010 13:54:36 +0000 Subject: [PATCH] add utility function for fault-tolerant lookup of list of objects by UID git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3996 fd906abe-77d9-0310-91a1-e0d9ade77398 --- util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/util.py b/util.py index cc43538..9a14469 100644 --- a/util.py +++ b/util.py @@ -101,6 +101,14 @@ def getUidForObject(obj, intIds=None): intIds = component.getUtility(IIntIds) return str(intIds.queryId(obj)) +def getObjectsForUids(uids, adapt=True): + intIds = component.getUtility(IIntIds) + result = [getObjectForUid(uid, intIds) for uid in uids] + if adapt: + from loops.common import adapted + return [adapted(obj) for obj in result if obj is not None] + return [obj for obj in result if obj is not None] + def getVarDirectory(request=None): varDir = None @@ -121,3 +129,5 @@ def getEtcDirectory(request=None): def getLogDirectory(request=None): varDir = getVarDirectory(request) return os.path.join(os.path.dirname(varDir), 'log') + +