VirtualMailManager/domain.py
branchv0.6.x
changeset 404 0c52094447b0
parent 402 8984b1f4e6e3
child 417 8209da83e256
equal deleted inserted replaced
403:a4f5d4cd886d 404:0c52094447b0
    12 import re
    12 import re
    13 from random import choice
    13 from random import choice
    14 
    14 
    15 from VirtualMailManager.constants import \
    15 from VirtualMailManager.constants import \
    16      ACCOUNT_AND_ALIAS_PRESENT, DOMAIN_ALIAS_EXISTS, DOMAIN_EXISTS, \
    16      ACCOUNT_AND_ALIAS_PRESENT, DOMAIN_ALIAS_EXISTS, DOMAIN_EXISTS, \
    17      DOMAIN_INVALID, DOMAIN_TOO_LONG, NO_SUCH_DOMAIN
    17      DOMAIN_INVALID, DOMAIN_TOO_LONG, NO_SUCH_DOMAIN, VMM_ERROR
    18 from VirtualMailManager.errors import DomainError as DomErr
    18 from VirtualMailManager.errors import VMMError, DomainError as DomErr
    19 from VirtualMailManager.pycompat import all, any
    19 from VirtualMailManager.pycompat import all, any
    20 from VirtualMailManager.quotalimit import QuotaLimit
    20 from VirtualMailManager.quotalimit import QuotaLimit
    21 from VirtualMailManager.transport import Transport
    21 from VirtualMailManager.transport import Transport
    22 
    22 
    23 
    23 
    24 MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
    24 MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
    25 RE_DOMAIN = re.compile(r"^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$")
    25 RE_DOMAIN = re.compile(r"^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$")
    26 _ = lambda msg: msg
    26 _ = lambda msg: msg
       
    27 cfg_dget = lambda option: None
    27 
    28 
    28 
    29 
    29 class Domain(object):
    30 class Domain(object):
    30     """Class to manage e-mail domains."""
    31     """Class to manage e-mail domains."""
    31     __slots__ = ('_directory', '_gid', '_name', '_qlimit', '_transport',
    32     __slots__ = ('_directory', '_gid', '_name', '_qlimit', '_transport',
   264         `quotalimit` : VirtualMailManager.quotalimit.QuotaLimit
   265         `quotalimit` : VirtualMailManager.quotalimit.QuotaLimit
   265           the new quota limit of the domain.
   266           the new quota limit of the domain.
   266         `force` : bool
   267         `force` : bool
   267           enforce new quota limit for all accounts, default `False`
   268           enforce new quota limit for all accounts, default `False`
   268         """
   269         """
       
   270         if cfg_dget('misc.dovecot_version') < 0x10102f00:
       
   271             raise VMMError(_(u'PostgreSQL-based dictionary quota requires '
       
   272                              u'Dovecot >= v1.1.2'), VMM_ERROR)
   269         self._chk_state()
   273         self._chk_state()
   270         assert isinstance(quotalimit, QuotaLimit)
   274         assert isinstance(quotalimit, QuotaLimit)
   271         if not force and quotalimit == self._qlimit:
   275         if not force and quotalimit == self._qlimit:
   272             return
   276             return
   273         self._update_tables('qid', quotalimit.qid, force)
   277         self._update_tables('qid', quotalimit.qid, force)
   457             else:
   461             else:
   458                 gids.append(gid)
   462                 gids.append(gid)
   459                 domains[gid] = [None, domain]
   463                 domains[gid] = [None, domain]
   460     return gids, domains
   464     return gids, domains
   461 
   465 
   462 del _
   466 del _, cfg_dget