equal
deleted
inserted
replaced
30 from VirtualMailManager.EmailAddress import EmailAddress |
30 from VirtualMailManager.EmailAddress import EmailAddress |
31 from VirtualMailManager.errors import VMMError, AliasError, DomainError, \ |
31 from VirtualMailManager.errors import VMMError, AliasError, DomainError, \ |
32 RelocatedError |
32 RelocatedError |
33 from VirtualMailManager.Relocated import Relocated |
33 from VirtualMailManager.Relocated import Relocated |
34 from VirtualMailManager.Transport import Transport |
34 from VirtualMailManager.Transport import Transport |
35 from VirtualMailManager.ext.Postconf import Postconf |
|
36 |
35 |
37 |
36 |
38 RE_DOMAIN_SEARCH = """^[a-z0-9-\.]+$""" |
37 RE_DOMAIN_SEARCH = """^[a-z0-9-\.]+$""" |
39 RE_MBOX_NAMES = """^[\x20-\x25\x27-\x7E]*$""" |
38 RE_MBOX_NAMES = """^[\x20-\x25\x27-\x7E]*$""" |
40 TYPE_ACCOUNT = 0x1 |
39 TYPE_ACCOUNT = 0x1 |
44 |
43 |
45 |
44 |
46 class Handler(object): |
45 class Handler(object): |
47 """Wrapper class to simplify the access on all the stuff from |
46 """Wrapper class to simplify the access on all the stuff from |
48 VirtualMailManager""" |
47 VirtualMailManager""" |
49 __slots__ = ('_Cfg', '_cfgFileName', '_dbh', '_postconf', '__warnings') |
48 __slots__ = ('_Cfg', '_cfgFileName', '_dbh', '__warnings') |
50 |
49 |
51 def __init__(self, skip_some_checks=False): |
50 def __init__(self, skip_some_checks=False): |
52 """Creates a new Handler instance. |
51 """Creates a new Handler instance. |
53 |
52 |
54 ``skip_some_checks`` : bool |
53 ``skip_some_checks`` : bool |
70 self._Cfg = Cfg(self._cfgFileName) |
69 self._Cfg = Cfg(self._cfgFileName) |
71 self._Cfg.load() |
70 self._Cfg.load() |
72 if not skip_some_checks: |
71 if not skip_some_checks: |
73 self._Cfg.check() |
72 self._Cfg.check() |
74 self._chkenv() |
73 self._chkenv() |
75 # will be moved to the Alias module |
|
76 #self._postconf = Postconf(self._Cfg.dget('bin.postconf')) |
|
77 |
74 |
78 def __findCfgFile(self): |
75 def __findCfgFile(self): |
79 for path in ['/root', '/usr/local/etc', '/etc']: |
76 for path in ['/root', '/usr/local/etc', '/etc']: |
80 tmp = os.path.join(path, 'vmm.cfg') |
77 tmp = os.path.join(path, 'vmm.cfg') |
81 if os.path.isfile(tmp): |
78 if os.path.isfile(tmp): |
488 """Creates a new `Alias` entry for the given *aliasaddress* with |
485 """Creates a new `Alias` entry for the given *aliasaddress* with |
489 the given *targetaddresses*.""" |
486 the given *targetaddresses*.""" |
490 alias = self.__getAlias(aliasaddress) |
487 alias = self.__getAlias(aliasaddress) |
491 destinations = [EmailAddress(address) for address in targetaddresses] |
488 destinations = [EmailAddress(address) for address in targetaddresses] |
492 warnings = [] |
489 warnings = [] |
493 destinations = alias.add_destinations(destinations, |
490 destinations = alias.add_destinations(destinations, warnings) |
494 long(self._postconf.read('virtual_alias_expansion_limit')), |
|
495 warnings) |
|
496 if warnings: |
491 if warnings: |
497 self.__warnings.append(_('Ignored destination addresses:')) |
492 self.__warnings.append(_('Ignored destination addresses:')) |
498 self.__warnings.extend((' * %s' % w for w in warnings)) |
493 self.__warnings.extend((' * %s' % w for w in warnings)) |
499 for destination in destinations: |
494 for destination in destinations: |
500 gid = get_gid(self._dbh, destination.domainname) |
495 gid = get_gid(self._dbh, destination.domainname) |