VirtualMailManager/handler.py
branchv0.6.x
changeset 444 95275b61ff8a
parent 441 1af5fe0683ce
child 447 c31d604e26d3
--- a/VirtualMailManager/handler.py	Tue Nov 01 23:37:06 2011 +0000
+++ b/VirtualMailManager/handler.py	Wed Nov 02 03:29:51 2011 +0000
@@ -740,29 +740,20 @@
                            acc.address, NO_SUCH_ACCOUNT)
         acc.update_transport(Transport(self._dbh, transport=transport))
 
-    def user_disable(self, emailaddress, services=None):
-        """Wrapper for Account.disable(*services)"""
-        if services is None:
-            services = []
-        else:
-            assert isinstance(services, list)
+    def user_services(self, emailaddress, *services):
+        """Wrapper around Account.update_serviceset()."""
+        kwargs = dict.fromkeys(SERVICES, False)
+        for service in set(services):
+            if service not in SERVICES:
+                raise VMMError(_(u"Unknown service: '%s'") % service,
+                               UNKNOWN_SERVICE)
+            kwargs[service] = True
         acc = self._get_account(emailaddress)
         if not acc:
             raise VMMError(_(u"The account '%s' does not exist.") %
                            acc.address, NO_SUCH_ACCOUNT)
-        acc.disable(*services)
-
-    def user_enable(self, emailaddress, services=None):
-        """Wrapper for Account.enable(*services)"""
-        if services is None:
-            services = []
-        else:
-            assert isinstance(services, list)
-        acc = self._get_account(emailaddress)
-        if not acc:
-            raise VMMError(_(u"The account '%s' does not exist.") %
-                           acc.address, NO_SUCH_ACCOUNT)
-        acc.enable(*services)
+        serviceset = ServiceSet(self._dbh, **kwargs)
+        acc.update_serviceset(serviceset)
 
     def relocated_add(self, emailaddress, targetaddress):
         """Creates a new `Relocated` entry in the database. If there is