* 'VirtualMailManager/Alias.py'
authorPascal Volk <neverseen@users.sourceforge.net>
Thu, 21 Aug 2008 01:23:31 +0000
changeset 52 c152d7714802
parent 51 f5ca21303871
child 53 5b50eb306d37
* 'VirtualMailManager/Alias.py' - call VirtualMailManager.chkEmailAddress() in Alias.__init__() * 'VirtualMailManager/VirtualMailManager.py' - VirtualMailManager.chkEmailAddress() checks also for len(domainname) > 0 * 'po/de.po' * 'po/vmm.pot' - updated
VirtualMailManager/Alias.py
VirtualMailManager/VirtualMailManager.py
VirtualMailManager/constants/ERROR.py
po/de.po
po/vmm.pot
--- a/VirtualMailManager/Alias.py	Wed Aug 20 02:22:43 2008 +0000
+++ b/VirtualMailManager/Alias.py	Thu Aug 21 01:23:31 2008 +0000
@@ -13,20 +13,25 @@
 __revision__ = 'rev '+'$Rev$'.split()[1]
 __date__ = '$Date$'.split()[1]
 
-from Exceptions import VMMAliasException
+from Exceptions import VMMAliasException as VMMAE
 from Domain import Domain
 import constants.ERROR as ERR
+import VirtualMailManager as VMM
 
 class Alias:
     """Class to manage e-mail accounts."""
     def __init__(self, dbh, address, destination=None):
         if address == destination:
-            raise VMMAliasException(
-                _(u'Address and destination are identical.'),
+            raise VMMAE(_(u"Address and destination are identical."),
                 ERR.ALIAS_ADDR_DEST_IDENTICAL)
         self._dbh = dbh
-        self._addr = address
-        self._dest = destination
+        self._addr = VMM.VirtualMailManager.chkEmailAddress(address)
+        if destination is None:
+            self._dest = None
+        elif destination.count('@'):
+            self._dest = VMM.VirtualMailManager.chkEmailAddress(destination)
+        else:
+            self._dest = VMM.VirtualMailManager.chkLocalpart(destination)
         self._localpart = None
         self._gid = 0
         self._isNew = False
@@ -34,9 +39,8 @@
         if not self._dest is None:
             self._exists()
         if self._isAccount():
-            raise VMMAliasException(
-            _(u"There is already an account with address '%s'") % self._addr,
-                ERR.ACCOUNT_EXISTS)
+            raise VMMAE(_(u"There is already an account with address »%s«.") %
+                    self._addr, ERR.ACCOUNT_EXISTS)
 
     def _exists(self):
         dbc = self._dbh.cursor()
@@ -65,13 +69,12 @@
         dom = Domain(self._dbh, d)
         self._gid = dom.getID()
         if self._gid == 0:
-            raise VMMAliasException(_(u"Domain '%s' doesn't exist.") % d,
+            raise VMMAE(_(u"The domain »%s« doesn't exist yet.") % d,
                 ERR.NO_SUCH_DOMAIN)
 
     def save(self):
         if self._dest is None:
-           raise VMMAliasException(
-               _('No destination address for alias denoted.'),
+           raise VMMAE(_(u"No destination address for alias denoted."),
                ERR.ALIAS_MISSING_DEST)
         if self._isNew:
             dbc = self._dbh.cursor()
@@ -80,8 +83,8 @@
             self._dbh.commit()
             dbc.close()
         else:
-            raise VMMAliasException(_("Alias already exists."),
-                ERR.ALIAS_EXISTS)
+            raise VMMAE(_(u"The alias »%s« already exists.") % self._addr,
+                    ERR.ALIAS_EXISTS)
 
     def getInfo(self):
         dbc = self._dbh.cursor()
@@ -95,8 +98,8 @@
                 targets.append(destination[0])
             return targets
         else:
-            raise VMMAliasException(_("Alias doesn't exists"),
-                ERR.NO_SUCH_ALIAS)
+            raise VMMAE(_(u"The alias »%s« doesn't exists.") % self._addr,
+                    ERR.NO_SUCH_ALIAS)
 
     def delete(self):
         dbc = self._dbh.cursor()
@@ -111,6 +114,6 @@
         if rowcount > 0:
             self._dbh.commit()
         else:
-            raise VMMAliasException(_("Alias doesn't exists"),
-                ERR.NO_SUCH_ALIAS)
+            raise VMMAE(_(u"The alias »%s« doesn't exists.") % self._addr,
+                    ERR.NO_SUCH_ALIAS)
 
--- a/VirtualMailManager/VirtualMailManager.py	Wed Aug 20 02:22:43 2008 +0000
+++ b/VirtualMailManager/VirtualMailManager.py	Thu Aug 21 01:23:31 2008 +0000
@@ -192,7 +192,11 @@
         except AttributeError:
             raise VMMException(_(u"»%s« looks not like an e-mail address.") %
                 address, ERR.INVALID_ADDRESS)
-        domain = VirtualMailManager.chkDomainname(domain)
+        if len(domain) > 0:
+            domain = VirtualMailManager.chkDomainname(domain)
+        else:
+            raise VMMException(_(u"Missing domain name after »%s@«.") %
+                    localpart, ERR.DOMAIN_NO_NAME)
         localpart = VirtualMailManager.chkLocalpart(localpart)
         return '%s@%s' % (localpart, domain)
     chkEmailAddress = staticmethod(chkEmailAddress)
@@ -219,12 +223,6 @@
         return clear0
 
     def __getAlias(self, address, destination=None):
-        address = VirtualMailManager.chkEmailAddress(address)
-        if not destination is None:
-            if destination.count('@'):
-                destination = VirtualMailManager.chkEmailAddress(destination)
-            else:
-                destination = VirtualMailManager.chkLocalpart(destination)
         self.__dbConnect()
         return Alias(self.__dbh, address, destination)
 
--- a/VirtualMailManager/constants/ERROR.py	Wed Aug 20 02:22:43 2008 +0000
+++ b/VirtualMailManager/constants/ERROR.py	Thu Aug 21 01:23:31 2008 +0000
@@ -20,23 +20,25 @@
 DOMAIN_ALIAS_EXISTS = 33
 DOMAIN_EXISTS = 34
 DOMAIN_INVALID = 35
-DOMAIN_TOO_LONG = 36
-FOUND_DOTS_IN_PATH = 37
-INVALID_ADDRESS = 38
-INVALID_AGUMENT = 39
-INVALID_OPTION = 40
-INVALID_SECTION = 41
-LOCALPART_INVALID = 42
-LOCALPART_TOO_LONG = 43
-MAILDIR_PERM_MISMATCH = 44
-MAILLOCATION_INIT = 45
-NOT_EXECUTABLE = 46
-NO_SUCH_ACCOUNT = 47
-NO_SUCH_ALIAS = 48
-NO_SUCH_BINARY = 49
-NO_SUCH_DIRECTORY = 50
-NO_SUCH_DOMAIN = 51
-TRANSPORT_INIT = 52
-UNKNOWN_MAILLOCATION_ID = 53
-UNKNOWN_SERVICE = 54
-UNKNOWN_TRANSPORT_ID = 55
+DOMAIN_NO_NAME = 36
+DOMAIN_TOO_LONG = 37
+FOUND_DOTS_IN_PATH = 38
+INVALID_ADDRESS = 39
+INVALID_AGUMENT = 40
+INVALID_OPTION = 41
+INVALID_SECTION = 42
+LOCALPART_INVALID = 43
+LOCALPART_TOO_LONG = 44
+MAILDIR_PERM_MISMATCH = 45
+MAILLOCATION_INIT = 46
+NOT_EXECUTABLE = 47
+NO_SUCH_ACCOUNT = 48
+NO_SUCH_ALIAS = 49
+NO_SUCH_BINARY = 50
+NO_SUCH_DIRECTORY = 51
+NO_SUCH_DOMAIN = 52
+NO_SUCH_DOMAIN_ALIAS = 53
+TRANSPORT_INIT = 54
+UNKNOWN_MAILLOCATION_ID = 55
+UNKNOWN_SERVICE = 56
+UNKNOWN_TRANSPORT_ID = 57
--- a/po/de.po	Wed Aug 20 02:22:43 2008 +0000
+++ b/po/de.po	Thu Aug 21 01:23:31 2008 +0000
@@ -6,8 +6,8 @@
 msgstr ""
 "Project-Id-Version: vmm 0.5\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-08-20 03:31+0200\n"
-"PO-Revision-Date: 2008-08-20 04:19+0200\n"
+"POT-Creation-Date: 2008-08-21 03:05+0200\n"
+"PO-Revision-Date: 2008-08-21 03:12+0200\n"
 "Last-Translator: Pascal Volk <p.volk@veb-it.de>\n"
 "Language-Team: German\n"
 "MIME-Version: 1.0\n"
@@ -66,27 +66,31 @@
 msgid "Address and destination are identical."
 msgstr "Alias- und Ziel-Adresse sind identisch."
 
-#: VirtualMailManager/Alias.py:38
+#: VirtualMailManager/Alias.py:42
 #, python-format
-msgid "There is already an account with address '%s'"
-msgstr "Es gibt bereits einen Accounts mit der Adresse '%s'"
+msgid "There is already an account with address »%s«."
+msgstr "Es gibt bereits einen Account mit der Adresse »%s«."
 
-#: VirtualMailManager/Alias.py:68
+#: VirtualMailManager/Alias.py:72 VirtualMailManager/Domain.py:171
+#: VirtualMailManager/Domain.py:195 VirtualMailManager/Domain.py:213
+#: VirtualMailManager/Domain.py:243
 #, python-format
-msgid "Domain '%s' doesn't exist."
-msgstr "Die Domain '%s' existiert nicht."
+msgid "The domain »%s« doesn't exist yet."
+msgstr "Die Domain »%s« existiert noch nicht."
 
-#: VirtualMailManager/Alias.py:74
+#: VirtualMailManager/Alias.py:77
 msgid "No destination address for alias denoted."
 msgstr "Keine Ziel-Adresse für den Alias angegeben."
 
-#: VirtualMailManager/Alias.py:83
-msgid "Alias already exists."
-msgstr "Der Alias existiert bereits."
+#: VirtualMailManager/Alias.py:86
+#, python-format
+msgid "The alias »%s« already exists."
+msgstr "Der Alias »%s« existiert bereits."
 
-#: VirtualMailManager/Alias.py:98 VirtualMailManager/Alias.py:114
-msgid "Alias doesn't exists"
-msgstr "Der Alias existiert nicht."
+#: VirtualMailManager/Alias.py:101 VirtualMailManager/Alias.py:117
+#, python-format
+msgid "The alias »%s« doesn't exists."
+msgstr "Der Alias »%s« existiert nicht."
 
 #: VirtualMailManager/Config.py:101
 #, python-format
@@ -134,12 +138,6 @@
 msgid "There are aliases."
 msgstr "Es sind noch Aliase vorhanden."
 
-#: VirtualMailManager/Domain.py:171 VirtualMailManager/Domain.py:195
-#: VirtualMailManager/Domain.py:213 VirtualMailManager/Domain.py:243
-#, python-format
-msgid "The domain »%s« doesn't exist yet."
-msgstr "Die Domain »%s« existiert noch nicht."
-
 #: VirtualMailManager/MailLocation.py:34
 msgid "Either mid or maillocation must be specified."
 msgstr "Entweder mid oder maillocation muss angegeben werden."
@@ -245,45 +243,50 @@
 msgid "»%s« looks not like an e-mail address."
 msgstr "»%s« sieht nicht wie eine E-Mail-Adresse aus."
 
-#: VirtualMailManager/VirtualMailManager.py:211
+#: VirtualMailManager/VirtualMailManager.py:198
+#, python-format
+msgid "Missing domain name after »%s@«."
+msgstr "Der Domain-Name nach »%s@« fehlt."
+
+#: VirtualMailManager/VirtualMailManager.py:215
 msgid "Enter new password: "
 msgstr "Neues Passwort eingeben: "
 
-#: VirtualMailManager/VirtualMailManager.py:214
+#: VirtualMailManager/VirtualMailManager.py:218
 msgid "Sorry, empty passwords are not permitted"
 msgstr "Entschuldigung, leere Passwörter sind nicht zulässig"
 
-#: VirtualMailManager/VirtualMailManager.py:215
+#: VirtualMailManager/VirtualMailManager.py:219
 msgid "Retype new password: "
 msgstr "Neues Passwort wiederholen: "
 
-#: VirtualMailManager/VirtualMailManager.py:218
+#: VirtualMailManager/VirtualMailManager.py:222
 msgid "Sorry, passwords do not match"
 msgstr "Entschuldigung, die Passwörter stimmen nicht überein"
 
-#: VirtualMailManager/VirtualMailManager.py:253
-#: VirtualMailManager/VirtualMailManager.py:323
+#: VirtualMailManager/VirtualMailManager.py:251
+#: VirtualMailManager/VirtualMailManager.py:321
 #, python-format
 msgid "No such directory: %s"
 msgstr "Verzeichnis nicht gefunden: %s"
 
-#: VirtualMailManager/VirtualMailManager.py:311
-msgid "Found \"..\" in userdir path."
+#: VirtualMailManager/VirtualMailManager.py:309
+msgid "Found \"..\" in home directory path."
 msgstr "\"..\" im Pfad zum Benutzerverzeichnis entdeckt."
 
-#: VirtualMailManager/VirtualMailManager.py:319
-msgid "Owner/group mismatch in userdir detected."
+#: VirtualMailManager/VirtualMailManager.py:317
+msgid "Owner/group mismatch in home directory detected."
 msgstr "Benutzerverzeichnis gehört dem/der falschen Benutzer/Gruppe."
 
-#: VirtualMailManager/VirtualMailManager.py:334
+#: VirtualMailManager/VirtualMailManager.py:332
 msgid "FATAL: \"..\" in domain directory path detected."
 msgstr "FATAL: \"..\" im Pfad zum Domain-Verzeichnis entdeckt."
 
-#: VirtualMailManager/VirtualMailManager.py:340
+#: VirtualMailManager/VirtualMailManager.py:338
 msgid "FATAL: group mismatch in domain directory detected"
 msgstr "FATAL: Domain-Verzeichnis gehört der falschen Gruppe"
 
-#: VirtualMailManager/VirtualMailManager.py:427
+#: VirtualMailManager/VirtualMailManager.py:425
 #, python-format
 msgid ""
 "Configurtion error: \"%s\"\n"
@@ -292,28 +295,28 @@
 "Konfigurations Fehler: \"%s\"\n"
 "(im Abschnitt \"connfig\", Option \"done\") Siehe auch: vmm.cfg(5)\n"
 
-#: VirtualMailManager/VirtualMailManager.py:447
+#: VirtualMailManager/VirtualMailManager.py:445
 #, python-format
 msgid "Invalid section: '%s'"
 msgstr "Ungültiger Abschnitt: '%s'"
 
-#: VirtualMailManager/VirtualMailManager.py:457
+#: VirtualMailManager/VirtualMailManager.py:455
 #, python-format
 msgid "Invalid argument: '%s'"
 msgstr "Ungültiges Argument: '%s'"
 
-#: VirtualMailManager/VirtualMailManager.py:467
-#: VirtualMailManager/VirtualMailManager.py:497
+#: VirtualMailManager/VirtualMailManager.py:465
+#: VirtualMailManager/VirtualMailManager.py:495
 #, python-format
 msgid "Invalid argument: »%s«"
 msgstr "Ungültiges Argument: »%s«"
 
-#: VirtualMailManager/VirtualMailManager.py:535
+#: VirtualMailManager/VirtualMailManager.py:533
 #, python-format
 msgid "The pattern »%s« contains invalid characters."
 msgstr "Das Muster »%s« enthält ungültige Zeichen."
 
-#: VirtualMailManager/VirtualMailManager.py:567
+#: VirtualMailManager/VirtualMailManager.py:565
 #, python-format
 msgid ""
 "The account has been successfully deleted from the database.\n"
@@ -326,7 +329,7 @@
 "    »%(directory)s«\n"
 "    Grund: %(raeson)s"
 
-#: VirtualMailManager/VirtualMailManager.py:599
+#: VirtualMailManager/VirtualMailManager.py:597
 msgid "Account doesn't exists"
 msgstr "Der Account existiert nicht"
 
@@ -465,11 +468,3 @@
 #: vmm:410
 msgid "Ouch"
 msgstr "Autsch"
-
-#: VirtualMailManager/VirtualMailManager.py:311
-msgid "Found \"..\" in home directory path."
-msgstr "\"..\" im Pfad zum Benutzerverzeichnis entdeckt."
-
-#: VirtualMailManager/VirtualMailManager.py:319
-msgid "Owner/group mismatch in home directory detected."
-msgstr "Benutzerverzeichnis gehört dem/der falschen Benutzer/Gruppe."
--- a/po/vmm.pot	Wed Aug 20 02:22:43 2008 +0000
+++ b/po/vmm.pot	Thu Aug 21 01:23:31 2008 +0000
@@ -3,10 +3,12 @@
 # This file is distributed under the same license as the vmm package.
 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
 #
+#, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: vmm 0.5\n"
-"POT-Creation-Date: 2008-08-20 03:31+0200\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-08-21 03:05+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -65,26 +67,30 @@
 msgid "Address and destination are identical."
 msgstr ""
 
-#: VirtualMailManager/Alias.py:38
+#: VirtualMailManager/Alias.py:42
 #, python-format
-msgid "There is already an account with address '%s'"
+msgid "There is already an account with address »%s«."
 msgstr ""
 
-#: VirtualMailManager/Alias.py:68
+#: VirtualMailManager/Alias.py:72 VirtualMailManager/Domain.py:171
+#: VirtualMailManager/Domain.py:195 VirtualMailManager/Domain.py:213
+#: VirtualMailManager/Domain.py:243
 #, python-format
-msgid "Domain '%s' doesn't exist."
+msgid "The domain »%s« doesn't exist yet."
 msgstr ""
 
-#: VirtualMailManager/Alias.py:74
+#: VirtualMailManager/Alias.py:77
 msgid "No destination address for alias denoted."
 msgstr ""
 
-#: VirtualMailManager/Alias.py:83
-msgid "Alias already exists."
+#: VirtualMailManager/Alias.py:86
+#, python-format
+msgid "The alias »%s« already exists."
 msgstr ""
 
-#: VirtualMailManager/Alias.py:98 VirtualMailManager/Alias.py:114
-msgid "Alias doesn't exists"
+#: VirtualMailManager/Alias.py:101 VirtualMailManager/Alias.py:117
+#, python-format
+msgid "The alias »%s« doesn't exists."
 msgstr ""
 
 #: VirtualMailManager/Config.py:101
@@ -133,12 +139,6 @@
 msgid "There are aliases."
 msgstr ""
 
-#: VirtualMailManager/Domain.py:171 VirtualMailManager/Domain.py:195
-#: VirtualMailManager/Domain.py:213 VirtualMailManager/Domain.py:243
-#, python-format
-msgid "The domain »%s« doesn't exist yet."
-msgstr ""
-
 #: VirtualMailManager/MailLocation.py:34
 msgid "Either mid or maillocation must be specified."
 msgstr ""
@@ -234,73 +234,78 @@
 msgid "»%s« looks not like an e-mail address."
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:211
-msgid "Enter new password: "
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:214
-msgid "Sorry, empty passwords are not permitted"
+#: VirtualMailManager/VirtualMailManager.py:198
+#, python-format
+msgid "Missing domain name after »%s@«."
 msgstr ""
 
 #: VirtualMailManager/VirtualMailManager.py:215
-msgid "Retype new password: "
+msgid "Enter new password: "
 msgstr ""
 
 #: VirtualMailManager/VirtualMailManager.py:218
+msgid "Sorry, empty passwords are not permitted"
+msgstr ""
+
+#: VirtualMailManager/VirtualMailManager.py:219
+msgid "Retype new password: "
+msgstr ""
+
+#: VirtualMailManager/VirtualMailManager.py:222
 msgid "Sorry, passwords do not match"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:253
-#: VirtualMailManager/VirtualMailManager.py:323
+#: VirtualMailManager/VirtualMailManager.py:251
+#: VirtualMailManager/VirtualMailManager.py:321
 #, python-format
 msgid "No such directory: %s"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:311
-msgid "Found \"..\" in userdir path."
+#: VirtualMailManager/VirtualMailManager.py:309
+msgid "Found \"..\" in home directory path."
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:319
-msgid "Owner/group mismatch in userdir detected."
+#: VirtualMailManager/VirtualMailManager.py:317
+msgid "Owner/group mismatch in home directory detected."
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:334
+#: VirtualMailManager/VirtualMailManager.py:332
 msgid "FATAL: \"..\" in domain directory path detected."
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:340
+#: VirtualMailManager/VirtualMailManager.py:338
 msgid "FATAL: group mismatch in domain directory detected"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:427
+#: VirtualMailManager/VirtualMailManager.py:425
 #, python-format
 msgid ""
 "Configurtion error: \"%s\"\n"
 "(in section \"connfig\", option \"done\") see also: vmm.cfg(5)\n"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:447
+#: VirtualMailManager/VirtualMailManager.py:445
 #, python-format
 msgid "Invalid section: '%s'"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:457
+#: VirtualMailManager/VirtualMailManager.py:455
 #, python-format
 msgid "Invalid argument: '%s'"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:467
-#: VirtualMailManager/VirtualMailManager.py:497
+#: VirtualMailManager/VirtualMailManager.py:465
+#: VirtualMailManager/VirtualMailManager.py:495
 #, python-format
 msgid "Invalid argument: »%s«"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:535
+#: VirtualMailManager/VirtualMailManager.py:533
 #, python-format
 msgid "The pattern »%s« contains invalid characters."
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:567
+#: VirtualMailManager/VirtualMailManager.py:565
 #, python-format
 msgid ""
 "The account has been successfully deleted from the database.\n"
@@ -309,7 +314,7 @@
 "    Reason: %(raeson)s"
 msgstr ""
 
-#: VirtualMailManager/VirtualMailManager.py:599
+#: VirtualMailManager/VirtualMailManager.py:597
 msgid "Account doesn't exists"
 msgstr ""
 
@@ -445,11 +450,3 @@
 #: vmm:410
 msgid "Ouch"
 msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:311
-msgid "Found \"..\" in home directory path."
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:319
-msgid "Owner/group mismatch in home directory detected."
-msgstr ""