VMM/domain: set_{directory,transport} make sure the domain is new. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Tue, 10 Aug 2010 04:31:46 +0000
branchv0.6.x
changeset 363 502d59f4bb34
parent 362 c2e8eab2616d
child 365 61fdd77d2e65
VMM/domain: set_{directory,transport} make sure the domain is new. Assertions could be optimized away.
VirtualMailManager/domain.py
--- a/VirtualMailManager/domain.py	Tue Aug 10 04:10:54 2010 +0000
+++ b/VirtualMailManager/domain.py	Tue Aug 10 04:31:46 2010 +0000
@@ -132,7 +132,10 @@
         `basedir` : basestring
           The base directory of all domains
         """
-        assert self._new and self._directory is None
+        if not self._new:
+            raise DomErr(_(u"The domain '%s' already exists.") % self._name,
+                         DOMAIN_EXISTS)
+        assert self._directory is None
         self._set_gid()
         self._directory = os.path.join(basedir, choice(MAILDIR_CHARS),
                                        str(self._gid))
@@ -150,7 +153,10 @@
         `transport` : VirtualMailManager.Transport
           The transport of the new Domain
         """
-        assert self._new and isinstance(transport, Transport)
+        if not self._new:
+            raise DomErr(_(u"The domain '%s' already exists.") % self._name,
+                         DOMAIN_EXISTS)
+        assert isinstance(transport, Transport)
         self._transport = transport
 
     def save(self):