VirtualMailManager/Relocated.py
branchv0.6.x
changeset 198 02d467e4fbab
parent 197 d2712e8c724e
child 202 43e7c8b440da
equal deleted inserted replaced
197:d2712e8c724e 198:02d467e4fbab
     6     VirtualMailManager.Relocated
     6     VirtualMailManager.Relocated
     7 
     7 
     8     Virtual Mail Manager's Relocated class to handle relocated users.
     8     Virtual Mail Manager's Relocated class to handle relocated users.
     9 """
     9 """
    10 
    10 
    11 from VirtualMailManager.Domain import Domain
    11 from VirtualMailManager.Domain import get_gid
    12 from VirtualMailManager.EmailAddress import EmailAddress
    12 from VirtualMailManager.EmailAddress import EmailAddress
    13 from VirtualMailManager.Exceptions import VMMRelocatedException as VMMRE
    13 from VirtualMailManager.Exceptions import VMMRelocatedException as VMMRE
    14 from VirtualMailManager.constants.ERROR import NO_SUCH_DOMAIN, \
    14 from VirtualMailManager.constants.ERROR import \
    15      NO_SUCH_RELOCATED, RELOCATED_ADDR_DEST_IDENTICAL, RELOCATED_EXISTS
    15      NO_SUCH_RELOCATED, RELOCATED_ADDR_DEST_IDENTICAL, RELOCATED_EXISTS
    16 
    16 
    17 
    17 
    18 _ = lambda msg: msg
    18 _ = lambda msg: msg
    19 
    19 
    31         if isinstance(address, EmailAddress):
    31         if isinstance(address, EmailAddress):
    32             self._addr = address
    32             self._addr = address
    33         else:
    33         else:
    34             raise TypeError("Argument 'address' is not an EmailAddress")
    34             raise TypeError("Argument 'address' is not an EmailAddress")
    35         self._dbh = dbh
    35         self._dbh = dbh
    36         self._gid = 0
    36         self._gid = get_gid(self._dbh, self._addr.domainname)
    37         self._dest = None
    37         self._dest = None
    38 
    38 
    39         self.__set_gid()
       
    40         self.__load()
    39         self.__load()
    41 
       
    42     def __set_gid(self):
       
    43         """Sets the `_gid` attribute, based on the `_addr.domainname`."""
       
    44         dom = Domain(self._dbh, self._addr.domainname)
       
    45         self._gid = dom.getID()
       
    46         if self._gid == 0:
       
    47             raise VMMRE(_(u"The domain ā€œ%sā€ doesn't exist.") %
       
    48                         self._addr.domainname, NO_SUCH_DOMAIN)
       
    49 
    40 
    50     def __load(self):
    41     def __load(self):
    51         """Loads the destination address from the database into the
    42         """Loads the destination address from the database into the
    52         `_dest` attribute."""
    43         `_dest` attribute."""
    53         dbc = self._dbh.cursor()
    44         dbc = self._dbh.cursor()