diff -r 1fc1f82c662f -r 15c873f94ba6 VirtualMailManager/Account.py --- a/VirtualMailManager/Account.py Fri Aug 22 16:25:15 2008 +0000 +++ b/VirtualMailManager/Account.py Fri Aug 22 20:00:50 2008 +0000 @@ -13,7 +13,7 @@ __revision__ = 'rev '+'$Rev$'.split()[1] __date__ = '$Date$'.split()[1] -from Exceptions import VMMAccountException +from Exceptions import VMMAccountException as AccE from Domain import Domain from Transport import Transport from MailLocation import MailLocation @@ -36,9 +36,8 @@ self._setAddr() self._exists() if self._isAlias(): - raise VMMAccountException( - _(u"There is already an alias with the address »%s«.") % address, - ERR.ALIAS_EXISTS) + raise AccE(_(u"There is already an alias with the address »%s«.") %\ + address, ERR.ALIAS_EXISTS) def _exists(self): dbc = self._dbh.cursor() @@ -69,7 +68,7 @@ dom = Domain(self._dbh, d) self._gid = dom.getID() if self._gid == 0: - raise VMMAccountException(_(u"Domain »%s« doesn't exist.") % d, + raise AccE(_(u"The domain »%s« doesn't exist yet.") % d, ERR.NO_SUCH_DOMAIN) self._base = dom.getDir() self._tid = dom.getTransportID() @@ -88,11 +87,11 @@ if not isinstance(state, bool): return False if not service in ['smtp', 'pop3', 'imap', 'managesieve', 'all', None]: - raise VMMAccountException(_(u"Unknown service »%s«.") % service, - ERR.UNKNOWN_SERVICE) + raise AccE(_(u"Unknown service »%s«.") % service, + ERR.UNKNOWN_SERVICE) if self._uid < 1: - raise VMMAccountException(_(u"The account »%s« doesn't exists.") % - self._addr, ERR.NO_SUCH_ACCOUNT) + raise AccE(_(u"The account »%s« doesn't exists.") % self._addr, + ERR.NO_SUCH_ACCOUNT) dbc = self._dbh.cursor() if service in ['smtp', 'pop3', 'imap', 'managesieve']: dbc.execute( @@ -143,13 +142,13 @@ self._dbh.commit() dbc.close() else: - raise VMMAccountException(_(u'The account »%s« already exists.') % - self._addr, ERR.ACCOUNT_EXISTS) + raise AccE(_(u'The account »%s« already exists.') % self._addr, + ERR.ACCOUNT_EXISTS) def modify(self, what, value): if self._uid == 0: - raise VMMAccountException(_(u"The account »%s« doesn't exists.") % - self._addr, ERR.NO_SUCH_ACCOUNT) + raise AccE(_(u"The account »%s« doesn't exists.") % self._addr, + ERR.NO_SUCH_ACCOUNT) if what not in ['name', 'password', 'transport']: return False dbc = self._dbh.cursor() @@ -175,8 +174,8 @@ info = dbc.fetchone() dbc.close() if info is None: - raise VMMAccountException(_(u"The account »%s« doesn't exists.") % - self._addr, ERR.NO_SUCH_ACCOUNT) + raise AccE(_(u"The account »%s« doesn't exists.") % self._addr, + ERR.NO_SUCH_ACCOUNT) else: keys = ['name', 'uid', 'gid', 'maildir', 'transport', 'smtp', 'pop3', 'imap', 'managesieve'] @@ -203,19 +202,17 @@ self._dbh.commit() dbc.close() else: - raise VMMAccountException(_(u"The account »%s« doesn't exists.") % - self._addr, ERR.NO_SUCH_ACCOUNT) + raise AccE(_(u"The account »%s« doesn't exists.") % self._addr, + ERR.NO_SUCH_ACCOUNT) def getAccountByID(uid, dbh): try: uid = long(uid) except ValueError: - raise VMMAccountException(_(u'uid must be an int/long.'), - ERR.INVALID_AGUMENT) + raise AccE(_(u'uid must be an int/long.'), ERR.INVALID_AGUMENT) if uid < 1: - raise VMMAccountException(_(u'uid must be greater than 0.'), - ERR.INVALID_AGUMENT) + raise AccE(_(u'uid must be greater than 0.'), ERR.INVALID_AGUMENT) dbc = dbh.cursor() dbc.execute("SELECT local_part||'@'|| domain_name.domainname AS address,\ uid, users.gid FROM users LEFT JOIN domain_name ON (domain_name.gid \ @@ -223,9 +220,8 @@ info = dbc.fetchone() dbc.close() if info is None: - raise VMMAccountException( - _(u"There is no account with the UID »%d«.") % uid, - ERR.NO_SUCH_ACCOUNT) + raise AccE(_(u"There is no account with the UID »%d«.") % uid, + ERR.NO_SUCH_ACCOUNT) keys = ['address', 'uid', 'gid'] info = dict(zip(keys, info)) return info