How can I scale all objects in the scene about the origin using Python? I'm currently writing a small script to help ease exporting objects made in Blender to the Unreal Engine, and one of the things I need to do is scale all mesh objects by 100 about the origin (0,0,0).

Although I have working code, the way I'm doing it seems a bit obtuse and I was wondering if there is a more direct way to do it. This is the code I have:

for ob in context.scene.objects:
  if ob.type == 'MESH':
    ob.scale *= 100
    ob.location *= 100
    ob.select = True
    scn.objects.active = ob
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    ob.select = False


Because of the selection stuff, in order not to lose the user's selection, I also have a bunch of code to save and restore the selected and active objects, which I'd rather not have. I am also not 100% sure if the scaling code is working flawlessly or not. It seems OK, but there is also bpy.ops.transform.resize, which might be more reliable, but then I need a bunch more code in order to set the 3d cursor position to 0,0,0. Is there a simple function along the lines of ob.set_scale(value=(100,100,100), pivot=(0,0,0), apply_transform=True)?
No solution, but a hint (cannot comment):

Your code runs the danger of scaling parented objects more than once.
You could filter/only scale objects with no parent (root scene objects)...like so:

root_objects = []
for obj in context.scene.objects:
    if not obj.parent:
        root_objects.append(obj)

for obj in root_objects:
    ...