Set physics type in bge using python? I'm trying to set up a scene using a script that places a bunch of cubes in random locations throughout the screen and sets their physics type to rigid body. Ideally, I'd like to have one cube be an agent whose actions can be controlled via a different script. How do I set objects' physics type en masse using python in the game engine? 
I've tried 

ActiveObj.game.physics_type = 'RIGID_BODY'
ActiveObj.game.use_collision_bounds = 1


as well as

for obj in bpy.data.objects:
     bpy.ops.rigidbody.object_add(type='ACTIVE')


but, obviously, neither works in the game engine. How do I get around this?
It's easy to turn a rigid body static and back again. Start with a rigid body, and then you can suspend/restore the dynamics:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
own.suspendDynamics()
#OR
own.restoreDynamics()




A slightly more hacky way to turn a rigid body static is to set it's mass to infinite (ie no force will have an effect).

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
own.mass = float('inf')


To make it rigid body again, set it's mass back to a proper number



To make an object dynamic is hard as BGE doesn't have access to the inertia tensor/radius of gyration. Even setting the angular velocity cap to 0.0 doesn't work. I guess you'd have to, every frame, set it's angular velocity to zero and restore it's orientation.

(untested code):

import bge

own = bge.logic.getCurrentController().owner
if 'ori' not in own:
    own['ori'] = own.worldOrientation.copy()
own.worldOrientation = own['ori']
own.worldAngularVelocity = [0.0, 0.0, 0.0]