I have an app written in python. I want to give my users the ability to manipulate the apps objects by allowing them to run their own scripts. They are likely to make errors in their scripts. If there is an error I want to ensure that the app doesn't stop running. I'd like to embed a debugger in my app to help them debug their scripts.
e.g. I define a point class in my app in shapes.py:
class QVPoint(object):
def __init__(self, x, y):
self.x = x
self.y = y
def addPoint(self, aPoint):
self.x = self.x + aPoint.x
self.y = self.y + aPoint.y
I want to enable them to run scripts like:
from shapes import QVPoint
a = QVPoint(1,1)
a.addPoint(QVPoint(2,2))
print "<" + str(a.x) + ',' + str(a.y) + ">"
print "<%d,%d>" % (a.x, a.y)
print 'done'
I figure this must use the interpreter, the debugger but I'm not sure on two counts, 1) how to expose objects that are created in the App to the script, and 2) how to ensure that the app doesn't stop if a bug causes the script to stop.
I'm sure this must have been asked before but I can't find it. All answers welcome.
Many thx
David