connectors/PYRO_dialog.py
changeset 2334 d1470c052662
parent 2329 e5703dc8848e
child 2492 7dd551ac2fa0
equal deleted inserted replaced
2333:81abf93b4684 2334:d1470c052662
    12 
    12 
    13 
    13 
    14 model = [('host',_("Host:")),
    14 model = [('host',_("Host:")),
    15          ('port',_("Port:"))]
    15          ('port',_("Port:"))]
    16 
    16 
    17 secure_model = model + [('ID',_("ID:"))]
    17 # (scheme, model, secure)
    18 
    18 models = [("LOCAL", [], False), ("PYRO", model, False), ("PYROS", model, True)]
    19 models = [("LOCAL", []), ("PYRO",model), ("PYROS",secure_model)]
       
    20 
    19 
    21 Schemes = list(zip(*models)[0])
    20 Schemes = list(zip(*models)[0])
    22 
    21 
    23 ModelsDict = dict(models)
    22 _PerSchemeConf = {sch : (mod,sec) for sch,mod,sec in models}
    24 
    23 
    25 class PYRO_dialog(SchemeEditor):
    24 class PYRO_dialog(SchemeEditor):
    26     def __init__(self, scheme, *args, **kwargs):
    25     def __init__(self, scheme, *args, **kwargs):
    27         self.model = ModelsDict[scheme]
    26        
       
    27         # ID selector is enabled only on PYROS (secure)
       
    28         self.model, self.EnableIDSelector = _PerSchemeConf[scheme]
       
    29 
    28         SchemeEditor.__init__(self, scheme, *args, **kwargs)
    30         SchemeEditor.__init__(self, scheme, *args, **kwargs)
    29 
    31 
    30     def SetLoc(self, loc):
    32     def SetLoc(self, loc):
    31         hostport, ID = list(islice(chain(loc.split("#"), repeat("")),2))
    33         hostport, ID = list(islice(chain(loc.split("#"), repeat("")),2))
    32         host, port = list(islice(chain(hostport.split(":"), repeat("")),2))
    34         host, port = list(islice(chain(hostport.split(":"), repeat("")),2))
    36         if self.model:
    38         if self.model:
    37             fields = self.GetFields()
    39             fields = self.GetFields()
    38             template = "{host}"
    40             template = "{host}"
    39             if fields['port']:
    41             if fields['port']:
    40                 template += ":{port}" 
    42                 template += ":{port}" 
       
    43             if fields['ID']:
       
    44                 template += "#{ID}" 
    41 
    45 
    42             return template.format(**fields)
    46             return template.format(**fields)
    43         return ''
    47         return ''
    44 
    48