'Forcibly delete a script from this object.
Args:
key (str, optional): A script key or the path to a script (in the
latter case all scripts with this path will be deleted!)
If no key is given, delete *all* scripts on the object!'

def delete(self, key=None):

    delscripts = ScriptDB.objects.get_all_scripts_on_obj(self.obj, key=key)
    if (not delscripts):
        delscripts = [script for script in ScriptDB.objects.get_all_scripts_on_obj(self.obj) if (script.path == key)]
    num = 0
    for script in delscripts:
        num += script.stop()
    return num
