10 from connectors.SchemeEditor import SchemeEditor |
10 from connectors.SchemeEditor import SchemeEditor |
11 |
11 |
12 Schemes = ["WAMP", "WAMPS"] |
12 Schemes = ["WAMP", "WAMPS"] |
13 |
13 |
14 model = [('host', _("Host:")), |
14 model = [('host', _("Host:")), |
|
15 ('path', _("Path:")), |
15 ('port', _("Port:")), |
16 ('port', _("Port:")), |
16 ('realm', _("Realm:"))] |
17 ('realm', _("Realm:"))] |
17 |
18 |
18 |
19 |
19 class WAMP_dialog(SchemeEditor): |
20 class WAMP_dialog(SchemeEditor): |
22 self.EnableIDSelector = True |
23 self.EnableIDSelector = True |
23 SchemeEditor.__init__(self, *args, **kwargs) |
24 SchemeEditor.__init__(self, *args, **kwargs) |
24 |
25 |
25 # pylint: disable=unused-variable |
26 # pylint: disable=unused-variable |
26 def SetLoc(self, loc): |
27 def SetLoc(self, loc): |
27 hostport, realm, ID = list(islice(chain(loc.split("#"), repeat("")), 3)) |
28 hostportpath, realm, ID = list(islice(chain(loc.split("#"), repeat("")), 3)) |
|
29 hostport, path = list(islice(chain(hostportpath.split("/"), repeat("")), 2)) |
28 host, port = list(islice(chain(hostport.split(":"), repeat("")), 2)) |
30 host, port = list(islice(chain(hostport.split(":"), repeat("")), 2)) |
29 self.SetFields(locals()) |
31 self.SetFields(locals()) |
30 |
32 |
31 def GetLoc(self): |
33 def GetLoc(self): |
32 fields = self.GetFields() |
34 fields = self.GetFields() |
33 |
35 |
34 # TODO : input validation test |
36 # TODO : input validation test |
35 |
37 |
36 template = "{host}" + \ |
38 template = "{host}" + \ |
37 (":{port}" if fields['port'] else '') +\ |
39 (":{port}" if fields['port'] else '') +\ |
|
40 ("/{path}" if fields['path'] else '') +\ |
38 "#{realm}#{ID}" |
41 "#{realm}#{ID}" |
39 |
42 |
40 return template.format(**fields) |
43 return template.format(**fields) |