10 |
10 |
11 from VirtualMailManager.Domain import Domain |
11 from VirtualMailManager.Domain import Domain |
12 from VirtualMailManager.EmailAddress import EmailAddress |
12 from VirtualMailManager.EmailAddress import EmailAddress |
13 from VirtualMailManager.Transport import Transport |
13 from VirtualMailManager.Transport import Transport |
14 from VirtualMailManager.constants.ERROR import \ |
14 from VirtualMailManager.constants.ERROR import \ |
15 ACCOUNT_EXISTS, ACCOUNT_MISSING_PASSWORD, ALIAS_EXISTS, ALIAS_PRESENT, \ |
15 ACCOUNT_EXISTS, ACCOUNT_MISSING_PASSWORD, ALIAS_PRESENT, \ |
16 INVALID_AGUMENT, NO_SUCH_ACCOUNT, NO_SUCH_DOMAIN, RELOCATED_EXISTS, \ |
16 INVALID_AGUMENT, NO_SUCH_ACCOUNT, NO_SUCH_DOMAIN, \ |
17 UNKNOWN_MAILLOCATION_NAME, UNKNOWN_SERVICE |
17 UNKNOWN_MAILLOCATION_NAME, UNKNOWN_SERVICE |
18 from VirtualMailManager.errors import AccountError as AErr |
18 from VirtualMailManager.errors import AccountError as AErr |
19 from VirtualMailManager.maillocation import MailLocation, known_format |
19 from VirtualMailManager.maillocation import MailLocation, known_format |
20 from VirtualMailManager.pycompat import all |
20 from VirtualMailManager.pycompat import all |
21 |
21 |
83 if not known_format(maillocation): |
83 if not known_format(maillocation): |
84 raise AErr(_(u'Unknown mail_location mailbox format: %r') % |
84 raise AErr(_(u'Unknown mail_location mailbox format: %r') % |
85 maillocation, UNKNOWN_MAILLOCATION_NAME) |
85 maillocation, UNKNOWN_MAILLOCATION_NAME) |
86 self._mid = MailLocation(format=maillocation).mid |
86 self._mid = MailLocation(format=maillocation).mid |
87 if not self._tid: |
87 if not self._tid: |
88 self._tid = self._domain.tid |
88 self._tid = self._domain.transport.tid |
89 self._set_uid() |
89 self._set_uid() |
90 |
90 |
91 def _switch_state(self, state, dcvers, service): |
91 def _switch_state(self, state, dcvers, service): |
92 """Switch the state of the Account's services on or off. See |
92 """Switch the state of the Account's services on or off. See |
93 Account.enable()/Account.disable() for more information.""" |
93 Account.enable()/Account.disable() for more information.""" |
370 {'count': a_count, 'address': self._addr}, |
370 {'count': a_count, 'address': self._addr}, |
371 ALIAS_PRESENT) |
371 ALIAS_PRESENT) |
372 dbc.close() |
372 dbc.close() |
373 |
373 |
374 |
374 |
375 def getAccountByID(uid, dbh): |
375 def get_account_by_uid(uid, dbh): |
376 """Search an Account by its UID. |
376 """Search an Account by its UID. |
|
377 |
|
378 This function returns a dict (keys: 'address', 'gid' and 'uid'), if an |
|
379 Account with the given *uid* exists. |
377 |
380 |
378 Argument: |
381 Argument: |
379 |
382 |
380 `uid` : long |
383 `uid` : long |
381 The Account unique ID. |
384 The Account unique ID. |