+ def validate_type(self, variable_type, value):
+
+ # ideally we should use the "validate_*" methods in PLCAPI or
+ # even declare some checks along with the default
+ # configuration (using RELAX NG?) but this shall work for now.
+ def ip_validator(val):
+ import socket
+ try:
+ socket.inet_aton(val)
+ return True
+ except: return False
+
+ validators = {
+ 'email' : lambda val: re.match('\A[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9._\-]+\.[a-zA-Z]+\Z', val),
+ 'ip': ip_validator
+ }
+
+ # validate it if not a know type.
+ validator = validators.get(variable_type, lambda x: True)
+ return validator(value)
+
+