MeVisLab Web Toolkit Reference
Loading...
Searching...
No Matches
MLABRemote.py
Go to the documentation of this file.
2# Copyright 2011, MeVis Medical Solutions AG
3#
4# The user may use this file in accordance with the license agreement provided with
5# the Software or, alternatively, in accordance with the terms contained in a
6# written agreement between the user and MeVis Medical Solutions AG.
7#
8# For further information use the contact form at https://www.mevislab.de/contact
9#
10
11
13
14
15
18 def __init__(self):
19 self._module = None
21
22 def setup(self, module):
23 self._module = module
25
26
28 def callOnModule(self, method, *args):
29 self._callInternal(method, *args)
30
31 def callWithResultOnModule(self, callback, method, *args):
32 self._callWithResultInternal(callback, method, *args)
33
34 def call(self, method, *args):
35 self._callInternal("::" + method, *args)
36
37 def callWithResult(self, callback, method, *args):
38 self._callWithResultInternal(callback, "::" + method, *args)
39
40 def _callInternal(self, method, *args):
41 self._module.callRemoteFunction(method, args)
42
43 def _callWithResultInternal(self, callback, method, *args):
44 self._module.callRemoteFunction(method, args, callback)
45
46 def getModule(self):
47 return self._module
48
50 # if the MDL tag allowedRemoteCalls is not given, then all calls are allowed and we do
51 # not need to add the common calls here
52 commands = self._module.mdlTree().findChild("Commands")
53 if commands:
54 allowedCallsTree = commands.findChild("allowedRemoteCalls")
55 if allowedCallsTree:
56 self._allowedRemoteCalls.update(allowedCallsTree.getValue().split(","))
58
60 tree = self._module.mdlTree()
61 commands = tree.findChild("Commands")
62 if not commands:
63 commands = tree.append("Commands", "")
64 allowedCallsTree = commands.findChild("allowedRemoteCalls")
65 if allowedCallsTree:
66 allowedCallsTree.setValue(",".join(self._allowedRemoteCalls))
67 else:
68 commands.append("allowedRemoteCalls", ",".join(self._allowedRemoteCalls))
69
70 def addAllowedRemoteCalls(self, allowedRemoteCalls):
71 self._allowedRemoteCalls.update(allowedRemoteCalls)
73
74
75
77MLABRemote = MLABRemoteClass()
78
79
80
84 MLABRemote.setup(module)
85 return MLABRemote
86
87
88
90def allowedRemoteCall(decoratedMethod):
91 MLABRemote.addAllowedRemoteCalls((decoratedMethod.__name__,))
92 return decoratedMethod
The class of the MLABRemote object.
Definition MLABRemote.py:17
call(self, method, *args)
Definition MLABRemote.py:34
addAllowedRemoteCalls(self, allowedRemoteCalls)
Definition MLABRemote.py:70
_callWithResultInternal(self, callback, method, *args)
Definition MLABRemote.py:43
_callInternal(self, method, *args)
Definition MLABRemote.py:40
callWithResultOnModule(self, callback, method, *args)
Definition MLABRemote.py:31
callWithResult(self, callback, method, *args)
Definition MLABRemote.py:37
allowedRemoteCall(decoratedMethod)
Decorator to allow remote calls to python functions.
Definition MLABRemote.py:90
setupRemoteContext(module)
This initializes the MLABRemote object.
Definition MLABRemote.py:83
callOnModule(self, method, *args)
Calls the given method with the given arguments in the web client context.
Definition MLABRemote.py:28