761 acc.address, NO_SUCH_ACCOUNT) |
761 acc.address, NO_SUCH_ACCOUNT) |
762 acc.modify('name', name) |
762 acc.modify('name', name) |
763 |
763 |
764 def user_quotalimit(self, emailaddress, bytes_, messages=0): |
764 def user_quotalimit(self, emailaddress, bytes_, messages=0): |
765 """Wrapper for Account.update_quotalimit(QuotaLimit).""" |
765 """Wrapper for Account.update_quotalimit(QuotaLimit).""" |
766 if not all(isinstance(i, (int, long)) for i in (bytes_, messages)): |
|
767 raise TypeError("'bytes_' and 'messages' have to be " |
|
768 "integers or longs.") |
|
769 acc = self._get_account(emailaddress) |
766 acc = self._get_account(emailaddress) |
770 if not acc: |
767 if not acc: |
771 raise VMMError(_(u"The account '%s' does not exist.") % |
768 raise VMMError(_(u"The account '%s' does not exist.") % |
772 acc.address, NO_SUCH_ACCOUNT) |
769 acc.address, NO_SUCH_ACCOUNT) |
773 acc.update_quotalimit(QuotaLimit(self._dbh, bytes=bytes_, |
770 if bytes_ == 'default': |
774 messages=messages)) |
771 quotalimit = None |
|
772 else: |
|
773 if not all(isinstance(i, (int, long)) for i in (bytes_, messages)): |
|
774 raise TypeError("'bytes_' and 'messages' have to be " |
|
775 "integers or longs.") |
|
776 quotalimit = QuotaLimit(self._dbh, bytes=bytes_, |
|
777 messages=messages) |
|
778 acc.update_quotalimit(quotalimit) |
775 |
779 |
776 def user_transport(self, emailaddress, transport): |
780 def user_transport(self, emailaddress, transport): |
777 """Wrapper for Account.update_transport(Transport).""" |
781 """Wrapper for Account.update_transport(Transport).""" |
778 if not isinstance(transport, basestring) or not transport: |
782 if not isinstance(transport, basestring) or not transport: |
779 raise VMMError(_(u"Could not accept transport: '%s'") % transport, |
783 raise VMMError(_(u"Could not accept transport: '%s'") % transport, |
780 INVALID_ARGUMENT) |
784 INVALID_ARGUMENT) |
781 acc = self._get_account(emailaddress) |
785 acc = self._get_account(emailaddress) |
782 if not acc: |
786 if not acc: |
783 raise VMMError(_(u"The account '%s' does not exist.") % |
787 raise VMMError(_(u"The account '%s' does not exist.") % |
784 acc.address, NO_SUCH_ACCOUNT) |
788 acc.address, NO_SUCH_ACCOUNT) |
785 acc.update_transport(Transport(self._dbh, transport=transport)) |
789 transport = None if transport == 'default' \ |
|
790 else Transport(self._dbh, transport=transport) |
|
791 acc.update_transport(transport) |
786 |
792 |
787 def user_services(self, emailaddress, *services): |
793 def user_services(self, emailaddress, *services): |
788 """Wrapper around Account.update_serviceset().""" |
794 """Wrapper around Account.update_serviceset().""" |
789 kwargs = dict.fromkeys(SERVICES, False) |
|
790 for service in set(services): |
|
791 if service not in SERVICES: |
|
792 raise VMMError(_(u"Unknown service: '%s'") % service, |
|
793 UNKNOWN_SERVICE) |
|
794 kwargs[service] = True |
|
795 acc = self._get_account(emailaddress) |
795 acc = self._get_account(emailaddress) |
796 if not acc: |
796 if not acc: |
797 raise VMMError(_(u"The account '%s' does not exist.") % |
797 raise VMMError(_(u"The account '%s' does not exist.") % |
798 acc.address, NO_SUCH_ACCOUNT) |
798 acc.address, NO_SUCH_ACCOUNT) |
799 serviceset = ServiceSet(self._dbh, **kwargs) |
799 if len(services) == 1 and services[0] == 'default': |
|
800 serviceset = None |
|
801 else: |
|
802 kwargs = dict.fromkeys(SERVICES, False) |
|
803 for service in set(services): |
|
804 if service not in SERVICES: |
|
805 raise VMMError(_(u"Unknown service: '%s'") % service, |
|
806 UNKNOWN_SERVICE) |
|
807 kwargs[service] = True |
|
808 serviceset = ServiceSet(self._dbh, **kwargs) |
800 acc.update_serviceset(serviceset) |
809 acc.update_serviceset(serviceset) |
801 |
810 |
802 def relocated_add(self, emailaddress, targetaddress): |
811 def relocated_add(self, emailaddress, targetaddress): |
803 """Creates a new `Relocated` entry in the database. If there is |
812 """Creates a new `Relocated` entry in the database. If there is |
804 already a relocated user with the given *emailaddress*, only the |
813 already a relocated user with the given *emailaddress*, only the |