Example #1
0
def from_addr_check(form, field):
    "Check from address"
    if (not EMAIL_RE.match(field.data) and not DOM_RE.match(field.data)
            and not IPV4_RE.match(field.data) and not
            IPV4_NET_OR_RANGE_RE.match(field.data) and not
            ipaddr_is_valid(field.data)):
        raise validators.ValidationError(
            _('Provide either a valid IP, email,'
            ' Domain address, or IP network or range'))
Example #2
0
def from_addr_check(form, field):
    "Check from address"
    if (not EMAIL_RE.match(field.data) and not DOM_RE.match(field.data)
            and not IPV4_RE.match(field.data)
            and not IPV4_NET_OR_RANGE_RE.match(field.data)
            and not ipaddr_is_valid(field.data)):
        raise validators.ValidationError(
            _('Provide either a valid IP, email,'
              ' Domain address, or IP network or range'))
Example #3
0
def _set_type(obj):
    "Set type of object"
    if EMAIL_RE.match(obj.from_address):
        obj.from_addr_type = 1
        return
    if DOM_RE.match(obj.from_address):
        obj.from_addr_type = 2
        return
    if IPV4_NET_OR_RANGE_RE.match(obj.from_address):
        obj.from_addr_type = 3
        return
    if ipaddr_is_valid(obj.from_address):
        obj.from_addr_type = 4
        return