equal
deleted
inserted
replaced
11 __author__ = 'Pascal Volk <p.volk@veb-it.de>' |
11 __author__ = 'Pascal Volk <p.volk@veb-it.de>' |
12 __version__ = VERSION |
12 __version__ = VERSION |
13 __revision__ = 'rev '+'$Rev$'.split()[1] |
13 __revision__ = 'rev '+'$Rev$'.split()[1] |
14 __date__ = '$Date$'.split()[1] |
14 __date__ = '$Date$'.split()[1] |
15 |
15 |
|
16 import gettext |
|
17 |
16 from Exceptions import VMMAccountException |
18 from Exceptions import VMMAccountException |
17 from Domain import Domain |
19 from Domain import Domain |
18 from Transport import Transport |
20 from Transport import Transport |
19 from MailLocation import MailLocation |
21 from MailLocation import MailLocation |
20 import constants.ERROR as ERR |
22 import constants.ERROR as ERR |
|
23 |
|
24 gettext.bindtextdomain('vmm', '/usr/local/share/locale') |
|
25 gettext.textdomain('vmm') |
|
26 _ = gettext.gettext |
21 |
27 |
22 class Account: |
28 class Account: |
23 """Class to manage e-mail accounts.""" |
29 """Class to manage e-mail accounts.""" |
24 def __init__(self, dbh, address, password=None): |
30 def __init__(self, dbh, address, password=None): |
25 self._dbh = dbh |
31 self._dbh = dbh |
34 self._passwd = password |
40 self._passwd = password |
35 self._setAddr() |
41 self._setAddr() |
36 self._exists() |
42 self._exists() |
37 if self._isAlias(): |
43 if self._isAlias(): |
38 raise VMMAccountException( |
44 raise VMMAccountException( |
39 ('There is already an alias with address »%s«' % address, |
45 (_('There is already an alias with address »%s«') % address, |
40 ERR.ALIAS_EXISTS)) |
46 ERR.ALIAS_EXISTS)) |
41 |
47 |
42 def _exists(self): |
48 def _exists(self): |
43 dbc = self._dbh.cursor() |
49 dbc = self._dbh.cursor() |
44 dbc.execute("SELECT uid, mid, tid FROM users \ |
50 dbc.execute("SELECT uid, mid, tid FROM users \ |
66 def _setAddr(self): |
72 def _setAddr(self): |
67 self._localpart, d = self._addr.split('@') |
73 self._localpart, d = self._addr.split('@') |
68 dom = Domain(self._dbh, d) |
74 dom = Domain(self._dbh, d) |
69 self._gid = dom.getID() |
75 self._gid = dom.getID() |
70 if self._gid == 0: |
76 if self._gid == 0: |
71 raise VMMAccountException(("Domain »%s« doesn't exist." % d, |
77 #raise VMMAccountException(("Domain »%s« doesn't exist." % d, |
72 ERR.NO_SUCH_DOMAIN)) |
78 errmsg = _('Domain »%s« does not exists.') |
|
79 raise VMMAccountException((errmsg % d, ERR.NO_SUCH_DOMAIN)) |
73 self._base = dom.getDir() |
80 self._base = dom.getDir() |
74 self._tid = dom.getTransportID() |
81 self._tid = dom.getTransportID() |
75 |
82 |
76 def _setID(self): |
83 def _setID(self): |
77 dbc = self._dbh.cursor() |
84 dbc = self._dbh.cursor() |