Commit cd5862fa authored by Gero Müller's avatar Gero Müller
Browse files

add get/clear_workspace_instance

parent 3af7876d
......@@ -30,8 +30,7 @@ class DemoController(AbstractController):
# in this example, we use the DemoRpc class to obtain the file list
# (of course, a call to "ros.listdir" would have the same effect)
demorpc_module = "vispa.extensions.demo.workspace.DemoRpc"
demorpc = vispa.workspace.get_instance(demorpc_module)
demorpc = self.extension.get_workspace_instance("DemoRpc")
files = demorpc.ls(path)
# we can use the "success" method implemented in the
......
......@@ -8,10 +8,9 @@ from vispa.controller import AbstractController
class DummyController(AbstractController):
_workspace_class_name = "vispa.extensions.dummy.workspace.DummyRpc"
def __init__(self):
AbstractController.__init__(self)
self.extension = None
@cherrypy.expose
def data(self):
......@@ -20,7 +19,7 @@ class DummyController(AbstractController):
rsys = vispa.workspace.module("sys")
content += "<p>sys.path: %s</p>" % rsys.path
dummyrpc = vispa.workspace.get_instance(self._workspace_class_name)
dummyrpc = self.extension.get_workspace_instance("DummyRpc")
content += "<p>dummy: %s</p>" % dummyrpc.dummy()
return content
......@@ -12,10 +12,8 @@ from vispa.server import AbstractExtension
class TerminalController(AbstractController):
_workspace_class_name = "vispa.extensions.terminal.workspace.Terminal"
def _terminal(self, tid):
return vispa.workspace.get_instance(self._workspace_class_name, tid)
return self.extension.get_workspace_instance("Terminal", tid)
@cherrypy.expose
def open(self):
......
......@@ -66,6 +66,7 @@ class AbstractExtension(object):
:param filename filename relative to extension directory
"""
controller.extension = self
self.server.controller.mount_extension_controller(self.name(),
controller)
......@@ -79,6 +80,21 @@ class AbstractExtension(object):
local = os.path.join(class_dir, directory)
remote = os.path.join('vispa', 'extensions', self.name(), directory)
vispa.workspace.add_directory_files(local, remote)
self.__workspace_directory = directory
def get_workspace_instance(self, name, key=None, user=None,
workspace=None, db=None):
classname = ".".join(["vispa.extensions", self.name(),
self.__workspace_directory, name])
return vispa.workspace.get_instance(classname, key, user,
workspace, db)
def clear_workspace_instance(self, name, key=None, user=None,
workspace=None, db=None):
classname = ".".join(["vispa.extensions", self.name(),
self.__workspace_directory, name])
return vispa.workspace.clear_instance(classname, key, user,
workspace, db)
class Server(object):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment