Allow easier monkey patching of WAMP connector Session class
authorEdouard Tisserant
Tue, 18 Dec 2018 14:12:16 +0100
changeset 2472 897687a3c982
parent 2471 9d5c291b510f
child 2473 1d64d283d0bd
Allow easier monkey patching of WAMP connector Session class
connectors/WAMP/__init__.py
--- a/connectors/WAMP/__init__.py	Tue Dec 18 14:10:43 2018 +0100
+++ b/connectors/WAMP/__init__.py	Tue Dec 18 14:12:16 2018 +0100
@@ -27,6 +27,7 @@
 from __future__ import print_function
 import sys
 import traceback
+from functools import partial
 from threading import Thread, Event
 from six import text_type as text
 
@@ -66,7 +67,7 @@
 }
 
 
-def WAMP_connector_factory(uri, confnodesroot):
+def _WAMP_connector_factory(cls, uri, confnodesroot):
     """
     WAMP://127.0.0.1:12345/path#realm#ID
     WAMPS://127.0.0.1:12345/path#realm#ID
@@ -88,7 +89,7 @@
             extra={"ID": ID})
         session_factory = wamp.ApplicationSessionFactory(
             config=component_config)
-        session_factory.session = WampSession
+        session_factory.session = cls
 
         # create a WAMP-over-WebSocket transport client factory
         transport_factory = WampWebSocketClientFactory(
@@ -157,3 +158,5 @@
     # TODO : PSK.UpdateID()
 
     return WampPLCObjectProxy
+
+WAMP_connector_factory = partial(_WAMP_connector_factory, WampSession)