def convertAtom(oldAF, newAF, atom):
    """Convert an atom from one AtomFactory to another.
    
    @param oldAF            : The old AtomFactory to which atom belongs
    @param newAF            : The new AtomFactory
    @param atom             : The atom to convert
    @return                 : The converted atom
    @raise Exception        : If atom cannot be found in oldAF
    """
    o = oldAF.get_object(atom)
    if o not in newAF:
        raise Exception, "%r not in newAF" % o
    return newAF[o]