VirtualMailManager/maillocation.py
branchv0.6.x
changeset 450 fd4aa073015f
parent 366 d6573da35b5f
child 568 14abdd04ddf5
equal deleted inserted replaced
449:6826acb9b0a7 450:fd4aa073015f
     8     Virtual Mail Manager's maillocation module to handle Dovecot's
     8     Virtual Mail Manager's maillocation module to handle Dovecot's
     9     mail_location setting for accounts.
     9     mail_location setting for accounts.
    10 
    10 
    11 """
    11 """
    12 
    12 
    13 from VirtualMailManager.constants import \
    13 from VirtualMailManager.constants import MAILLOCATION_INIT
    14      MAILLOCATION_INIT, UNKNOWN_MAILLOCATION_ID
       
    15 from VirtualMailManager.errors import MailLocationError as MLErr
    14 from VirtualMailManager.errors import MailLocationError as MLErr
    16 from VirtualMailManager.pycompat import all
    15 from VirtualMailManager.pycompat import all
    17 
    16 
    18 
    17 
    19 __all__ = ('MailLocation', 'known_format')
    18 __all__ = ('MailLocation', 'known_format')
   118                     'maillocation WHERE mid = %u AND '
   117                     'maillocation WHERE mid = %u AND '
   119                     'maillocation.fid = mailboxformat.fid' % mid)
   118                     'maillocation.fid = mailboxformat.fid' % mid)
   120         result = dbc.fetchone()
   119         result = dbc.fetchone()
   121         dbc.close()
   120         dbc.close()
   122         if not result:
   121         if not result:
   123             raise MLErr(_(u'Unknown mail_location id: %u') % mid,
   122             raise ValueError('Unknown mail_location id specified: %r' % mid)
   124                         UNKNOWN_MAILLOCATION_ID)
       
   125         self._mid = mid
   123         self._mid = mid
   126         self._mbfmt, self._directory = result
   124         self._mbfmt, self._directory = result
   127 
   125 
   128     def _load_by_names(self, mbfmt, directory):
   126     def _load_by_names(self, mbfmt, directory):
   129         """Try to load mail_location relevant information by *mbfmt* and
   127         """Try to load mail_location relevant information by *mbfmt* and