connectors/__init__.py
changeset 2338 2c3222433244
parent 2329 e5703dc8848e
child 2339 48b4eba13064
equal deleted inserted replaced
2337:8689ce77076f 2338:2c3222433244
    62 def ConnectorFactory(uri, confnodesroot):
    62 def ConnectorFactory(uri, confnodesroot):
    63     """
    63     """
    64     Return a connector corresponding to the URI
    64     Return a connector corresponding to the URI
    65     or None if cannot connect to URI
    65     or None if cannot connect to URI
    66     """
    66     """
    67     servicetype = uri.split("://")[0].upper()
    67     scheme = uri.split("://")[0].upper()
    68     if servicetype == "LOCAL":
    68     if scheme == "LOCAL":
    69         # Local is special case
    69         # Local is special case
    70         # pyro connection to local runtime
    70         # pyro connection to local runtime
    71         # started on demand, listening on random port
    71         # started on demand, listening on random port
    72         servicetype = "PYRO"
    72         scheme = "PYRO"
    73         runtime_port = confnodesroot.AppFrame.StartLocalRuntime(
    73         runtime_port = confnodesroot.AppFrame.StartLocalRuntime(
    74             taskbaricon=True)
    74             taskbaricon=True)
    75         uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
    75         uri = "PYROLOC://127.0.0.1:" + str(runtime_port)
    76     elif servicetype in connectors:
    76     elif scheme in connectors:
    77         pass
    77         pass
    78     elif servicetype[-1] == 'S' and servicetype[:-1] in connectors:
    78     elif scheme[-1] == 'S' and scheme[:-1] in connectors:
    79         servicetype = servicetype[:-1]
    79         scheme = scheme[:-1]
    80     else:
    80     else:
    81         return None
    81         return None
    82 
    82 
    83     # import module according to uri type
    83     # import module according to uri type
    84     connectorclass = connectors[servicetype]()
       
    85     return connectorclass(uri, confnodesroot)
    84     return connectorclass(uri, confnodesroot)
       
    85     connectorclass = connectors[scheme]()
    86 
    86 
    87 
    87 
    88 def EditorClassFromScheme(scheme):
    88 def EditorClassFromScheme(scheme):
    89     _Import_Dialogs()
    89     _Import_Dialogs()
    90     return per_URI_connectors.get(scheme, None) 
    90     return per_URI_connectors.get(scheme, None)