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:
parent
1343619d11
commit
cffadbdf14
1 changed files with 10 additions and 0 deletions
10
util.py
10
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')
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue