Converted to new-style class, added __slots__.
authorPascal Volk <neverseen@users.sourceforge.net>
Thu, 20 Aug 2009 06:12:33 +0000
changeset 122 30abf0abf8f8
parent 121 7ccc05774118
child 123 626c008a4a04
Converted to new-style class, added __slots__.
VirtualMailManager/Alias.py
VirtualMailManager/AliasDomain.py
VirtualMailManager/Domain.py
VirtualMailManager/MailLocation.py
VirtualMailManager/Relocated.py
--- a/VirtualMailManager/Alias.py	Thu Aug 20 03:28:26 2009 +0000
+++ b/VirtualMailManager/Alias.py	Thu Aug 20 06:12:33 2009 +0000
@@ -12,8 +12,9 @@
 import constants.ERROR as ERR
 import VirtualMailManager as VMM
 
-class Alias:
+class Alias(object):
     """Class to manage e-mail aliases."""
+    __slots__ = ('_addr', '_dest', '_gid', '_isNew', '_dbh')
     def __init__(self, dbh, address, destination=None):
         if isinstance(address, EmailAddress):
             self._addr = address
--- a/VirtualMailManager/AliasDomain.py	Thu Aug 20 03:28:26 2009 +0000
+++ b/VirtualMailManager/AliasDomain.py	Thu Aug 20 06:12:33 2009 +0000
@@ -10,8 +10,9 @@
 import constants.ERROR as ERR
 import VirtualMailManager as VMM
 
-class AliasDomain:
+class AliasDomain(object):
     """Class to manage e-mail alias domains."""
+    __slots__ = ('__gid', '__name', '_domain', '_dbh')
     def __init__(self, dbh, domainname, targetDomain=None):
         self._dbh = dbh
         self.__name = VMM.VirtualMailManager.chkDomainname(domainname)
--- a/VirtualMailManager/Domain.py	Thu Aug 20 03:28:26 2009 +0000
+++ b/VirtualMailManager/Domain.py	Thu Aug 20 06:12:33 2009 +0000
@@ -15,11 +15,12 @@
 
 MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
 
-class Domain:
+class Domain(object):
     """Class to manage e-mail domains."""
+    __slots__ = ('_basedir','_domaindir','_id','_name','_transport','_dbh')
     def __init__(self, dbh, domainname, basedir=None, transport=None):
         """Creates a new Domain instance.
-        
+
         Keyword arguments:
         dbh -- a pyPgSQL.PgSQL.connection
         domainname -- name of the domain (str)
@@ -106,7 +107,7 @@
 
     def _chkDelete(self, delUser, delAlias):
         """Checks dependencies for deletion.
-        
+
         Keyword arguments:
         delUser -- ignore available accounts (bool)
         delAlias -- ignore available aliases (bool)
@@ -276,7 +277,7 @@
         return aliasdomains
 
 def search(dbh, pattern=None, like=False):
-    if pattern is not None and like is False: 
+    if pattern is not None and like is False:
         pattern = VMM.VirtualMailManager.chkDomainname(pattern)
     sql = 'SELECT gid, domainname, is_primary FROM domain_name'
     if pattern is None:
--- a/VirtualMailManager/MailLocation.py	Thu Aug 20 03:28:26 2009 +0000
+++ b/VirtualMailManager/MailLocation.py	Thu Aug 20 06:12:33 2009 +0000
@@ -14,13 +14,14 @@
 
 RE_MAILLOCATION = """^\w{1,20}$"""
 
-class MailLocation:
+class MailLocation(object):
     """A wrapper class thats provide access to the maillocation table"""
+    __slots__ = ('__id', '__maillocation', '_dbh')
     def __init__(self, dbh, mid=None, maillocation=None):
         """Creates a new MailLocation instance.
 
         Either mid or maillocation must be specified.
-        
+
         Keyword arguments:
         dbh -- a pyPgSQL.PgSQL.connection
         mid -- the id of a maillocation (long)
--- a/VirtualMailManager/Relocated.py	Thu Aug 20 03:28:26 2009 +0000
+++ b/VirtualMailManager/Relocated.py	Thu Aug 20 06:12:33 2009 +0000
@@ -12,8 +12,9 @@
 import constants.ERROR as ERR
 import VirtualMailManager as VMM
 
-class Relocated:
+class Relocated(object):
     """Class to manage e-mail addresses of relocated users."""
+    __slots__ = ('_addr', '_dest', '_gid', '_isNew', '_dbh')
     def __init__(self, dbh, address, destination=None):
         if isinstance(address, EmailAddress):
             self._addr = address