ztfy/utils/catalog/__init__.py
changeset 65 c262ddb4d656
parent 42 cb2a0e2d3bbf
child 70 82d8de021806
equal deleted inserted replaced
64:a4367f6969e8 65:c262ddb4d656
    51     return intids
    51     return intids
    52 
    52 
    53 
    53 
    54 def getObjectId(object, intids_name='', request=None, context=None):
    54 def getObjectId(object, intids_name='', request=None, context=None):
    55     """Look for an object Id as recorded by given IIntIds utility"""
    55     """Look for an object Id as recorded by given IIntIds utility"""
       
    56     if object is None:
       
    57         return None
    56     if request is None:
    58     if request is None:
    57         request = request_utils.getRequest()
    59         request = request_utils.getRequest()
    58     intids = getIntIdUtility(intids_name, request, context)
    60     intids = getIntIdUtility(intids_name, request, context)
    59     if intids is not None:
    61     if intids is not None:
    60         return intids.queryId(object)
    62         return intids.queryId(object)
    61     return None
    63     return None
    62 
    64 
    63 
    65 
    64 def getObject(id, intids_name='', request=None, context=None):
    66 def getObject(id, intids_name='', request=None, context=None):
    65     """Look for an object recorded by given IIntIds utility and id"""
    67     """Look for an object recorded by given IIntIds utility and id"""
       
    68     if id is None:
       
    69         return None
    66     if request is None:
    70     if request is None:
    67         request = request_utils.getRequest()
    71         request = request_utils.getRequest()
    68     intids = getIntIdUtility(intids_name, request, context)
    72     intids = getIntIdUtility(intids_name, request, context)
    69     if intids is not None:
    73     if intids is not None:
    70         return intids.queryObject(id)
    74         return intids.queryObject(id)