How can I get a particular editor space in python?
Your code doesn't seem right, it should be

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'DOPESHEET_EDITOR':
        space_data = area.spaces.active
        break
else:
    space_data = None

if space_data is not None:
    pass


To avoid searching for the right area (which may or may not exist in current screen layout), it's possible to change bpy.context.area.type temporarily to the type you require.

However, I'm pretty sure what you actually want to do is:

bpy.context.object.animation_data.action = bpy.data.actions['The Name']