VMM/Alias.py: Replaced some %r with '%s'. v0.6.x
authorTobias Berling <mail@tobiasberling.de>
Sun, 18 Apr 2010 19:02:23 +0000
branchv0.6.x
changeset 257 5b8fde01e4f0
parent 256 ae80282301a3
child 259 6c699837b4d4
VMM/Alias.py: Replaced some %r with '%s'. VMM/AliasDomain.py: save(), switch(), delete(): Update AliasDomain._gid after database change. Added dbc.close() to AliasDomain.delete(). create_tables{,-dovecot-1.2.x}.pgsql: Fixed a typo.
VirtualMailManager/Alias.py
VirtualMailManager/AliasDomain.py
pgsql/create_tables-dovecot-1.2.x.pgsql
pgsql/create_tables.pgsql
--- a/VirtualMailManager/Alias.py	Sun Apr 18 15:42:46 2010 +0000
+++ b/VirtualMailManager/Alias.py	Sun Apr 18 19:02:23 2010 +0000
@@ -29,7 +29,7 @@
         self._dbh = dbh
         self._gid = get_gid(self._dbh, self._addr.domainname)
         if not self._gid:
-            raise AErr(_(u"The domain %r doesn't exist.") %
+            raise AErr(_(u"The domain '%s' doesn't exist.") %
                        self._addr.domainname, NO_SUCH_DOMAIN)
         self._dests = []
 
@@ -53,26 +53,26 @@
         if dcount == limit or dcount + count_new > limit:
             failed = True
             errmsg = _(
-u"""Can't add %(count_new)i new destination(s) to alias %(address)r.
+u"""Can't add %(count_new)i new destination(s) to alias '%(address)s'.
 Currently this alias expands into %(count)i/%(limit)i recipients.
 %(count_new)i additional destination(s) will render this alias unusable.
 Hint: Increase Postfix' virtual_alias_expansion_limit""")
         elif dcount > limit:
             failed = True
             errmsg = _(
-u"""Can't add %(count_new)i new destination(s) to alias %(address)r.
-This alias already exceeds it's expansion limit (%(count)i/%(limit)i).
+u"""Can't add %(count_new)i new destination(s) to alias '%(address)s'.
+This alias already exceeds its expansion limit (%(count)i/%(limit)i).
 So its unusable, all messages addressed to this alias will be bounced.
 Hint: Delete some destination addresses.""")
         if failed:
-            raise AErr(errmsg % {'address': str(self._addr), 'count': dcount,
+            raise AErr(errmsg % {'address': self._addr, 'count': dcount,
                                  'limit': limit, 'count_new': count_new},
                        ALIAS_EXCEEDS_EXPANSION_LIMIT)
 
     def __delete(self, destination=None):
         """Deletes a destination from the alias, if ``destination`` is
         not ``None``.  If ``destination`` is None, the alias with all
-        it's destination addresses will be deleted.
+        its destination addresses will be deleted.
 
         """
         dbc = self._dbh.cursor()
@@ -102,7 +102,7 @@
 
         Destinations, that are already assigned to the alias, will be
         removed from *destinations*.  When done, this method will return
-        a set with all destinations, that was saved in the database.
+        a set with all destinations, that were saved in the database.
         """
         destinations = set(destinations)
         assert destinations and \
@@ -134,12 +134,12 @@
         """Deletes the specified ``destination`` address from the alias."""
         assert isinstance(destination, EmailAddress)
         if not self._dests:
-            raise AErr(_(u"The alias %r doesn't exist.") % str(self._addr),
+            raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr,
                        NO_SUCH_ALIAS)
         if not destination in self._dests:
-            raise AErr(_(u"The address %(d)r isn't a destination of \
-the alias %(a)r.") %
-                       {'a': str(self._addr), 'd': str(destination)},
+            raise AErr(_(u"The address '%(d)s' isn't a destination of \
+the alias '%(a)s'.") %
+                       {'a': self._addr, 'd': destination},
                        NO_SUCH_ALIAS)
         self.__delete(destination)
         self._dests.remove(destination)
@@ -147,14 +147,14 @@
     def get_destinations(self):
         """Returns an iterator for all destinations of the alias."""
         if not self._dests:
-            raise AErr(_(u"The alias %r doesn't exist.") % str(self._addr),
+            raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr,
                        NO_SUCH_ALIAS)
         return iter(self._dests)
 
     def delete(self):
         """Deletes the alias with all its destinations."""
         if not self._dests:
-            raise AErr(_(u"The alias %r doesn't exist.") % str(self._addr),
+            raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr,
                        NO_SUCH_ALIAS)
         self.__delete()
         del self._dests[:]
--- a/VirtualMailManager/AliasDomain.py	Sun Apr 18 15:42:46 2010 +0000
+++ b/VirtualMailManager/AliasDomain.py	Sun Apr 18 19:02:23 2010 +0000
@@ -80,6 +80,7 @@
                     self._name, self._domain.gid)
         self._dbh.commit()
         dbc.close()
+        self._gid = self._domain.gid
 
     def info(self):
         """Returns a dict (keys: "alias" and "domain") with the names of the
@@ -124,6 +125,7 @@
                     self._domain.gid, self._gid, self._name)
         self._dbh.commit()
         dbc.close()
+        self._gid = self._domain.gid
 
     def delete(self):
         """Delete the AliasDomain's record form the database.
@@ -139,6 +141,8 @@
                     self._name)
         if dbc.rowcount > 0:
             self._dbh.commit()
+            self._gid = 0
+        dbc.close()
 
 
 del _
--- a/pgsql/create_tables-dovecot-1.2.x.pgsql	Sun Apr 18 15:42:46 2010 +0000
+++ b/pgsql/create_tables-dovecot-1.2.x.pgsql	Sun Apr 18 19:02:23 2010 +0000
@@ -41,7 +41,7 @@
 
 CREATE TABLE domain_data (
     gid         bigint NOT NULL DEFAULT nextval('domain_gid'),
-    tid         bigint NOT NULL DEFAULT 1, -- defualt transport
+    tid         bigint NOT NULL DEFAULT 1, -- default transport
     domaindir   varchar(40) NOT NULL, --/srv/mail/$RAND/4294967294
     CONSTRAINT  pkey_domain_data PRIMARY KEY (gid),
     CONSTRAINT  fkey_domain_data_tid_transport FOREIGN KEY (tid)
--- a/pgsql/create_tables.pgsql	Sun Apr 18 15:42:46 2010 +0000
+++ b/pgsql/create_tables.pgsql	Sun Apr 18 19:02:23 2010 +0000
@@ -41,7 +41,7 @@
 
 CREATE TABLE domain_data (
     gid         bigint NOT NULL DEFAULT nextval('domain_gid'),
-    tid         bigint NOT NULL DEFAULT 1, -- defualt transport
+    tid         bigint NOT NULL DEFAULT 1, -- default transport
     domaindir   varchar(40) NOT NULL, --/srv/mail/$RAND/4294967294
     CONSTRAINT  pkey_domain_data PRIMARY KEY (gid),
     CONSTRAINT  fkey_domain_data_tid_transport FOREIGN KEY (tid)