VirtualMailManager/domain.py
branchv0.7.x
changeset 653 cf07e4468934
parent 643 df1e3b67882a
child 671 a9d86ccac044
equal deleted inserted replaced
652:68d715ce6e1c 653:cf07e4468934
   497     Throws an `DomainError`, if the domain name is too long or doesn't
   497     Throws an `DomainError`, if the domain name is too long or doesn't
   498     look like a valid domain name (label.label.label).
   498     look like a valid domain name (label.label.label).
   499 
   499 
   500     """
   500     """
   501     if not RE_DOMAIN.match(domainname):
   501     if not RE_DOMAIN.match(domainname):
   502         domainname = domainname.encode('idna')
   502         domainname = domainname.encode('idna').decode()
   503     if len(domainname) > 255:
   503     if len(domainname) > 255:
   504         raise DomErr(_('The domain name is too long'), DOMAIN_TOO_LONG)
   504         raise DomErr(_('The domain name is too long'), DOMAIN_TOO_LONG)
   505     if not RE_DOMAIN.match(domainname):
   505     if not RE_DOMAIN.match(domainname):
   506         raise DomErr(_("The domain name '%s' is invalid") % domainname,
   506         raise DomErr(_("The domain name '%s' is invalid") % domainname,
   507                      DOMAIN_INVALID)
   507                      DOMAIN_INVALID)