MeVisLab Web Toolkit Reference
Toggle main menu visibility
Loading...
Searching...
No Matches
MLABRemote.py
Go to the documentation of this file.
1
#
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
17
class
MLABRemoteClass
:
18
def
__init__
(self):
19
self.
_module
=
None
20
self.
_allowedRemoteCalls
= set()
21
22
def
setup
(self, module):
23
self.
_module
= module
24
self.
_setupAllowedRemoteCalls
()
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
49
def
_setupAllowedRemoteCalls
(self):
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(
","
))
57
self.
_setAllowedRemoteCalls
()
58
59
def
_setAllowedRemoteCalls
(self):
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)
72
self.
_setAllowedRemoteCalls
()
73
74
75
77
MLABRemote =
MLABRemoteClass
()
78
79
80
83
def
setupRemoteContext
(module):
84
MLABRemote.setup(module)
85
return
MLABRemote
86
87
88
90
def
allowedRemoteCall
(decoratedMethod):
91
MLABRemote.addAllowedRemoteCalls((decoratedMethod.__name__,))
92
return
decoratedMethod
MLABRemote.MLABRemoteClass
The class of the MLABRemote object.
Definition
MLABRemote.py:17
MLABRemote.MLABRemoteClass.setup
setup(self, module)
Definition
MLABRemote.py:22
MLABRemote.MLABRemoteClass.call
call(self, method, *args)
Definition
MLABRemote.py:34
MLABRemote.MLABRemoteClass.addAllowedRemoteCalls
addAllowedRemoteCalls(self, allowedRemoteCalls)
Definition
MLABRemote.py:70
MLABRemote.MLABRemoteClass._allowedRemoteCalls
_allowedRemoteCalls
Definition
MLABRemote.py:20
MLABRemote.MLABRemoteClass._callWithResultInternal
_callWithResultInternal(self, callback, method, *args)
Definition
MLABRemote.py:43
MLABRemote.MLABRemoteClass._setAllowedRemoteCalls
_setAllowedRemoteCalls(self)
Definition
MLABRemote.py:59
MLABRemote.MLABRemoteClass._callInternal
_callInternal(self, method, *args)
Definition
MLABRemote.py:40
MLABRemote.MLABRemoteClass._module
_module
Definition
MLABRemote.py:19
MLABRemote.MLABRemoteClass.callWithResultOnModule
callWithResultOnModule(self, callback, method, *args)
Definition
MLABRemote.py:31
MLABRemote.MLABRemoteClass._setupAllowedRemoteCalls
_setupAllowedRemoteCalls(self)
Definition
MLABRemote.py:49
MLABRemote.MLABRemoteClass.getModule
getModule(self)
Definition
MLABRemote.py:46
MLABRemote.MLABRemoteClass.callWithResult
callWithResult(self, callback, method, *args)
Definition
MLABRemote.py:37
MLABRemote.MLABRemoteClass.__init__
__init__(self)
Definition
MLABRemote.py:18
MLABRemote.allowedRemoteCall
allowedRemoteCall(decoratedMethod)
Decorator to allow remote calls to python functions.
Definition
MLABRemote.py:90
MLABRemote.setupRemoteContext
setupRemoteContext(module)
This initializes the MLABRemote object.
Definition
MLABRemote.py:83
MLABRemote.MLABRemoteClass.callOnModule
callOnModule(self, method, *args)
Calls the given method with the given arguments in the web client context.
Definition
MLABRemote.py:28
MeVisLab
Standard
Modules
Scripts
python
MLABRemote.py
Generated by
1.18.0