# HG changeset patch
# User Pascal Volk <neverseen@users.sourceforge.net>
# Date 1281414706 0
# Node ID 502d59f4bb34d5220c2e4b1664eb3143ba845546
# Parent  c2e8eab2616dc1f51ffc866a0e4e9ace2eb9005c
VMM/domain: set_{directory,transport} make sure the domain is new.
Assertions could be optimized away.

diff -r c2e8eab2616d -r 502d59f4bb34 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):