#2486 ExposedCalls with register options as a dictionary. #2486
authordporopat <denis.poropat@smarteh.si>
Fri, 18 May 2018 11:05:49 +0200
branch#2486
changeset 2206 1e397afc36a9
parent 2205 4c74218b42e1
child 2207 c27b820cb96b
#2486 ExposedCalls with register options as a dictionary.
runtime/WampClient.py
tests/wamp/project_files/wampconf.json
--- a/runtime/WampClient.py	Mon May 14 13:05:54 2018 +0200
+++ b/runtime/WampClient.py	Fri May 18 11:05:49 2018 +0200
@@ -44,21 +44,19 @@
 _WampSecret = None
 
 ExposedCalls = [
-    "StartPLC",
-    "StopPLC",
-    "ForceReload",
-    "GetPLCstatus",
-    "NewPLC",
-    "MatchMD5",
-    "SetTraceVariablesList",
-    "GetTraceVariables",
-    "RemoteExec",
-    "GetLogMessage",
-    "ResetLogCount",
+    ("StartPLC", {}),
+    ("StopPLC", {}),
+    ("ForceReload", {}),
+    ("GetPLCstatus", {}),
+    ("NewPLC", {}),
+    ("MatchMD5", {}),
+    ("SetTraceVariablesList", {}),
+    ("GetTraceVariables", {}),
+    ("RemoteExec", {}),
+    ("GetLogMessage", {}),
+    ("ResetLogCount", {})
 ]
 
-ExposedProgressCalls = []
-
 # Those two lists are meant to be filled by customized runtime
 # or User python code.
 
@@ -108,26 +106,16 @@
         global _WampSession
         _WampSession = self
         ID = self.config.extra["ID"]
-        validRegisterOptions = {}
-
-        registerOptions = self.config.extra.get('registerOptions', None)
-        if registerOptions:
-            arguments = inspect.getargspec(types.RegisterOptions.__init__).args
-            validRegisterOptions = getValidOptins(registerOptions, arguments)
-            if validRegisterOptions:
-                registerOptions = types.RegisterOptions(**validRegisterOptions)
-                #print(_("Added custom register options"))
-
-        for name in ExposedCalls:
+
+        for name, kwargs in ExposedCalls:
+            try:
+                registerOptions = types.RegisterOptions(**kwargs)
+            except TypeError as e:
+                registerOptions = None
+                print(_("TypeError register option: {}".format(e)))
+
             yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions)
 
-        if ExposedProgressCalls:
-            validRegisterOptions["details_arg"] = 'details'
-            registerOptions = types.RegisterOptions(**validRegisterOptions)
-            # using progress, details argument must be added
-            for name in ExposedProgressCalls:
-                yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions)
-
         for name in SubscribedEvents:
             yield self.subscribe(GetCallee(name), unicode(name))
 
--- a/tests/wamp/project_files/wampconf.json	Mon May 14 13:05:54 2018 +0200
+++ b/tests/wamp/project_files/wampconf.json	Fri May 18 11:05:49 2018 +0200
@@ -8,10 +8,5 @@
         "autoPingTimeout": 20
     }, 
     "realm": "Automation", 
-    "registerOptions": {
-        "concurrency": 2, 
-        "invoke": "last", 
-        "match": "exact"
-    }, 
     "url": "ws://127.0.0.1:8888"
 }