Fetches CallDescriptor from the local database given a hash key representing the call. If it doesn't exist returns None.

    :param str hash: The sha1 hexdigest to look the CallDescriptor up by.

    :rtype: CallDescriptor corresponding to the hash passed or None if it wasn't found.

def fetch( hash ):
    """
    Fetches CallDescriptor from the local database given a hash key representing the call. If it doesn't exist returns None.

    :param str hash: The sha1 hexdigest to look the CallDescriptor up by.

    :rtype: CallDescriptor corresponding to the hash passed or None if it wasn't found.
    """
    res = select_io( hash )

    if res:
      p = { 'methodname': '', 'returnval': '', 'args': '', 'stack': '' }
      for packet in res:
        hash, stack, methodname, returnval, args, packet_num = packet
        p['methodname'] = p['methodname'] + methodname
        p['returnval']  = p['returnval'] + returnval
        p['args']       = p['args'] + args
        p['stack']      = p['stack'] + stack
                             
      return CallDescriptor( hash = hash,
                             stack = p['stack'],
                             method = p['methodname'],
                             returnval = pickle.loads( str( p['returnval'] ) ),
                             args = pickle.loads( str( p['args'] ) ) )
    return None