Make a trail inside the bge I've tried do to draw a curve with the bge module, assuming I have a list of locations :

for i in range(1, len(positions) - 1):
    bge.render.drawLine(positions[i - 1], positions[i], (1, 0, 0))


But the following doesn't work at all. What is wrong with this ?
This is the piece of code I've written, and I'd like to be able to draw the trajectory of the object.

import bge

own = bge.logic.getCurrentController().owner
scene = bge.logic.getCurrentScene()
own["positions"] = []
own.applyForce((1, 1, 1), 0)
own["positions"].append(own.worldPosition)
for i in range(1, len(own["positions"]) - 1):
    bge.render.drawLine(own["positions"][i - 1], own["positions"][i], (1, 0, 0))


EDIT:

Changed the script according to Chebhou's answer:

import bge
own = bge.logic.getCurrentController().owner
scene = bge.logic.getCurrentScene()
if "positions" not in own :
    own["positions"] = []
own.applyForce((1, 1, 1), 0)
own["positions"].append(own.worldPosition.copy())
for i in range(1, len(own["positions"]) - 1):
    bge.render.drawLine(own["positions"][i - 1], own["positions"][i], (1, 0, 0))
positions variable is being cleared at every execution of the script by the line own["positions"] = [] to prevent this replace that line with :

if 'positions' not in own :
    own["positions"] = []




Edit :
The position list was not extended properly it was taking pointers to the object position to fix this replace own["positions"].append(own.position) with own["positions"].append(own.position.copy())