12 format_domain_default |
12 format_domain_default |
13 from VirtualMailManager.constants import \ |
13 from VirtualMailManager.constants import \ |
14 ACCOUNT_EXISTS, ACCOUNT_MISSING_PASSWORD, ALIAS_PRESENT, \ |
14 ACCOUNT_EXISTS, ACCOUNT_MISSING_PASSWORD, ALIAS_PRESENT, \ |
15 INVALID_ARGUMENT, INVALID_MAIL_LOCATION, NO_SUCH_ACCOUNT, \ |
15 INVALID_ARGUMENT, INVALID_MAIL_LOCATION, NO_SUCH_ACCOUNT, \ |
16 NO_SUCH_DOMAIN, VMM_ERROR |
16 NO_SUCH_DOMAIN, VMM_ERROR |
|
17 from VirtualMailManager.common import validate_transport |
17 from VirtualMailManager.domain import Domain |
18 from VirtualMailManager.domain import Domain |
18 from VirtualMailManager.emailaddress import EmailAddress |
19 from VirtualMailManager.emailaddress import EmailAddress |
19 from VirtualMailManager.errors import VMMError, AccountError as AErr |
20 from VirtualMailManager.errors import VMMError, AccountError as AErr |
20 from VirtualMailManager.maillocation import MailLocation |
21 from VirtualMailManager.maillocation import MailLocation |
21 from VirtualMailManager.password import pwhash |
22 from VirtualMailManager.password import pwhash |
123 u">= v%(version)s.") % { |
124 u">= v%(version)s.") % { |
124 'mbfmt': maillocation.mbformat, |
125 'mbfmt': maillocation.mbformat, |
125 'version': version_str(maillocation.dovecot_version)}, |
126 'version': version_str(maillocation.dovecot_version)}, |
126 INVALID_MAIL_LOCATION) |
127 INVALID_MAIL_LOCATION) |
127 transport = self._transport or self._domain.transport |
128 transport = self._transport or self._domain.transport |
128 if not maillocation.postfix and \ |
129 validate_transport(transport, maillocation) |
129 transport.transport.lower() in ('virtual:', 'virtual'): |
|
130 raise AErr(_(u"Invalid transport '%(transport)s' for mailbox " |
|
131 u"format '%(mbfmt)s'.") % |
|
132 {'transport': transport, |
|
133 'mbfmt': maillocation.mbformat}, INVALID_MAIL_LOCATION) |
|
134 self._mail = maillocation |
130 self._mail = maillocation |
135 self._set_uid() |
131 self._set_uid() |
136 |
132 |
137 def _update_tables(self, column, value): |
133 def _update_tables(self, column, value): |
138 """Update various columns in the users table. |
134 """Update various columns in the users table. |
348 if transport == self._transport: |
344 if transport == self._transport: |
349 return |
345 return |
350 self._transport = transport |
346 self._transport = transport |
351 if transport is not None: |
347 if transport is not None: |
352 assert isinstance(transport, Transport) |
348 assert isinstance(transport, Transport) |
353 if transport.transport.lower() in ('virtual', 'virtual:') and \ |
349 validate_transport(transport, self._mail) |
354 not self._mail.postfix: |
|
355 raise AErr(_(u"Invalid transport '%(transport)s' for mailbox " |
|
356 u"format '%(mbfmt)s'.") % |
|
357 {'transport': transport, |
|
358 'mbfmt': self._mail.mbformat}, |
|
359 INVALID_MAIL_LOCATION) |
|
360 transport = transport.tid |
350 transport = transport.tid |
361 self._update_tables('tid', transport) |
351 self._update_tables('tid', transport) |
362 |
352 |
363 def _get_info_transport(self): |
353 def _get_info_transport(self): |
364 if self._transport: |
354 if self._transport: |