VMM/Domain: removed functions ace2idna() and idn2ascii().
domainname.encode('idna')/domainname.decode('idna') works too.
--- a/VirtualMailManager/Domain.py Wed May 12 07:40:59 2010 +0000
+++ b/VirtualMailManager/Domain.py Tue May 18 07:00:21 2010 +0000
@@ -10,7 +10,6 @@
import os
import re
-from encodings.idna import ToASCII, ToUnicode
from random import choice
from VirtualMailManager.constants.ERROR import \
@@ -319,23 +318,15 @@
return aliasdomains
-def ace2idna(domainname):
- """Converts the domain name `domainname` from ACE according to IDNA."""
- return u'.'.join([ToUnicode(lbl) for lbl in domainname.split('.') if lbl])
-
-
def check_domainname(domainname):
"""Returns the validated domain name `domainname`.
- It also converts the name of the domain from IDN to ASCII, if
- necessary.
-
Throws an `DomainError`, if the domain name is too long or doesn't
look like a valid domain name (label.label.label).
"""
if not RE_DOMAIN.match(domainname):
- domainname = idn2ascii(domainname)
+ domainname = domainname.encode('idna')
if len(domainname) > 255:
raise DomErr(_(u'The domain name is too long'), DOMAIN_TOO_LONG)
if not RE_DOMAIN.match(domainname):
@@ -359,11 +350,6 @@
return 0
-def idn2ascii(domainname):
- """Converts the idn domain name `domainname` into punycode."""
- return '.'.join([ToASCII(lbl) for lbl in domainname.split('.') if lbl])
-
-
def search(dbh, pattern=None, like=False):
"""'Search' for domains by *pattern* in the database.
--- a/VirtualMailManager/Handler.py Wed May 12 07:40:59 2010 +0000
+++ b/VirtualMailManager/Handler.py Tue May 18 07:00:21 2010 +0000
@@ -26,7 +26,7 @@
from VirtualMailManager.AliasDomain import AliasDomain
from VirtualMailManager.common import exec_ok
from VirtualMailManager.Config import Config as Cfg
-from VirtualMailManager.Domain import Domain, ace2idna, get_gid
+from VirtualMailManager.Domain import Domain, get_gid
from VirtualMailManager.EmailAddress import EmailAddress
from VirtualMailManager.errors import \
DomainError, NotRootError, PermissionError, VMMError
@@ -416,7 +416,8 @@
dom = self.__getDomain(domainname)
dominfo = dom.get_info()
if dominfo['domainname'].startswith('xn--'):
- dominfo['domainname'] += ' (%s)' % ace2idna(dominfo['domainname'])
+ dominfo['domainname'] += ' (%s)' % \
+ dominfo['domainname'].decode('idna')
if details is None:
return dominfo
elif details == 'accounts':