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