VirtualMailManager/catchall.py
changeset 608 0ed93eb8b364
parent 513 557c4703986c
child 611 8e9b0046bc8f
equal deleted inserted replaced
607:46454ff9d441 608:0ed93eb8b364
    64         dcount = len(self._dests)
    64         dcount = len(self._dests)
    65         failed = False
    65         failed = False
    66         if dcount == limit or dcount + count_new > limit:
    66         if dcount == limit or dcount + count_new > limit:
    67             failed = True
    67             failed = True
    68             errmsg = _(
    68             errmsg = _(
    69 u"""Cannot add %(count_new)i new destination(s) to catchall alias for
    69 u"""Cannot add %(count_new)i new destination(s) to catch-all alias for
    70 domain '%(domain)s'. Currently this alias expands into %(count)i/%(limit)i
    70 domain '%(domain)s'. Currently this alias expands into %(count)i/%(limit)i
    71 recipients. %(count_new)i additional destination(s) will render this alias
    71 recipients. %(count_new)i additional destination(s) will render this alias
    72 unusable.
    72 unusable.
    73 Hint: Increase Postfix' virtual_alias_expansion_limit""")
    73 Hint: Increase Postfix' virtual_alias_expansion_limit""")
    74         elif dcount > limit:
    74         elif dcount > limit:
    75             failed = True
    75             failed = True
    76             errmsg = _(
    76             errmsg = _(
    77 u"""Cannot add %(count_new)i new destination(s) to catchall alias for
    77 u"""Cannot add %(count_new)i new destination(s) to catch-all alias for
    78 domain '%(domain)s'. This alias already exceeds its expansion limit (%(count)i/%(limit)i).
    78 domain '%(domain)s'. This alias already exceeds its expansion limit (%(count)i/%(limit)i).
    79 So its unusable, all messages addressed to this alias will be bounced.
    79 So its unusable, all messages addressed to this alias will be bounced.
    80 Hint: Delete some destination addresses.""")
    80 Hint: Delete some destination addresses.""")
    81         if failed:
    81         if failed:
    82             raise AErr(errmsg % {'domain': self._domain, 'count': dcount,
    82             raise AErr(errmsg % {'domain': self._domain, 'count': dcount,
   141     def del_destination(self, destination):
   141     def del_destination(self, destination):
   142         """Deletes the specified ``destination`` address from the catchall
   142         """Deletes the specified ``destination`` address from the catchall
   143         alias."""
   143         alias."""
   144         assert isinstance(destination, EmailAddress)
   144         assert isinstance(destination, EmailAddress)
   145         if not self._dests:
   145         if not self._dests:
   146             raise AErr(_(u"There are no catchall aliases defined for "
   146             raise AErr(_(u"There are no catch-all aliases defined for "
   147                          u"domain '%s'.") % self._domain, NO_SUCH_ALIAS)
   147                          u"domain '%s'.") % self._domain, NO_SUCH_ALIAS)
   148         if not destination in self._dests:
   148         if not destination in self._dests:
   149             raise AErr(_(u"The address '%(addr)s' is not a destination of "
   149             raise AErr(_(u"The address '%(addr)s' is not a destination of "
   150                          u"the catchall alias for domain '%(domain)s'.")
   150                          u"the catch-all alias for domain '%(domain)s'.")
   151                        % {'addr': destination, 'domain': self._domain},
   151                        % {'addr': destination, 'domain': self._domain},
   152                        NO_SUCH_ALIAS)
   152                        NO_SUCH_ALIAS)
   153         self._delete(destination)
   153         self._delete(destination)
   154         self._dests.remove(destination)
   154         self._dests.remove(destination)
   155 
   155 
   156     def get_destinations(self):
   156     def get_destinations(self):
   157         """Returns an iterator for all destinations of the catchall alias."""
   157         """Returns an iterator for all destinations of the catchall alias."""
   158         if not self._dests:
   158         if not self._dests:
   159             raise AErr(_(u"There are no catchall aliases defined for "
   159             raise AErr(_(u"There are no catch-all aliases defined for "
   160                          u"domain '%s'.") % self._domain, NO_SUCH_ALIAS)
   160                          u"domain '%s'.") % self._domain, NO_SUCH_ALIAS)
   161         return iter(self._dests)
   161         return iter(self._dests)
   162 
   162 
   163     def delete(self):
   163     def delete(self):
   164         """Deletes all catchall destinations for the domain."""
   164         """Deletes all catchall destinations for the domain."""
   165         if not self._dests:
   165         if not self._dests:
   166             raise AErr(_(u"There are no catchall aliases defined for "
   166             raise AErr(_(u"There are no catch-all aliases defined for "
   167                          u"domain '%s'.") % self._domain, NO_SUCH_ALIAS)
   167                          u"domain '%s'.") % self._domain, NO_SUCH_ALIAS)
   168         self._delete()
   168         self._delete()
   169         del self._dests[:]
   169         del self._dests[:]
   170 
   170 
   171 del _, cfg_dget
   171 del _, cfg_dget