Your code contained a couple of errors.
1st error: The code to get the actuator that you are using to move and rotate your game object was missing.
2nd error: The code to get the key code (from the GameKeys module) for the WKEY was missing.
3rd error: getKeyStatus returns an integer. (link to getKeyStatus method)
0 = not active. 1 = just pressed. 2 = active. 3 = released
Try the code below.
# get the current controller
cont = GameLogic.getCurrentController()
# get owner
own = cont.getOwner()
# import GameKeys Module
# get sensor named key
keys = cont.getSensor("key")
# get actuator named motion
motion = cont.getActuator("motion")
# set variables
speed = 0.1
rspeed = 0.02
walk = 0.0
turn = 0.0
# get Game key code for W key
wKey = GameKeys.WKEY
# if get key status is 1 (just pressed)
if keys.getKeyStatus(wKey) == 1:
walk = speed
# move on local y axis
motion.setDLoc(0, walk, 0, True)
# rotate on world z axis
motion.setDRot(0, 0, turn, False)
# use actuator