##// END OF EJS Templates
validators: fix glob validator raise statement misplacement.
marcink -
r1129:97341a21 default
parent child Browse files
Show More
@@ -1,26 +1,25 b''
1 import os
1 import os
2 import re
2 import re
3
3
4 import ipaddress
4 import ipaddress
5 import colander
5 import colander
6
6
7 from rhodecode.translation import _
7 from rhodecode.translation import _
8 from rhodecode.lib.utils2 import glob2re
8 from rhodecode.lib.utils2 import glob2re
9
9
10
10
11 def ip_addr_validator(node, value):
11 def ip_addr_validator(node, value):
12 try:
12 try:
13 # this raises an ValueError if address is not IpV4 or IpV6
13 # this raises an ValueError if address is not IpV4 or IpV6
14 ipaddress.ip_network(value, strict=False)
14 ipaddress.ip_network(value, strict=False)
15 except ValueError:
15 except ValueError:
16 msg = _(u'Please enter a valid IPv4 or IpV6 address')
16 msg = _(u'Please enter a valid IPv4 or IpV6 address')
17 raise colander.Invalid(node, msg)
17 raise colander.Invalid(node, msg)
18
18
19
19
20 def glob_validator(node, value):
20 def glob_validator(node, value):
21 try:
21 try:
22 re.compile('^' + glob2re(value) + '$')
22 re.compile('^' + glob2re(value) + '$')
23 except Exception:
23 except Exception:
24 raise
25 msg = _(u'Invalid glob pattern')
24 msg = _(u'Invalid glob pattern')
26 raise colander.Invalid(node, msg)
25 raise colander.Invalid(node, msg)
General Comments 0
You need to be logged in to leave comments. Login now