How to uv unwrap object with python
This method works:

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'VIEW_3D':
        for region in area.regions:
            if region.type == 'WINDOW':
                override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
                bpy.ops.uv.smart_project(override)


the important thing is passing override to whatever operator you are trying to call, this forces it to take that context for a brief moment. You can read a little about it at http://www.blender.org/documentation/blender_python_api_2_72_release/bpy.ops.html?highlight=override