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
This commit is contained in:
helmutm 2010-09-15 13:54:36 +00:00
parent 1343619d11
commit cffadbdf14

10
util.py
View file

@ -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')