VirtualMailManager/Domain.py
changeset 122 30abf0abf8f8
parent 110 cb8b2f6a5fca
child 133 2d5c4745efec
equal deleted inserted replaced
121:7ccc05774118 122:30abf0abf8f8
    13 import VirtualMailManager as VMM
    13 import VirtualMailManager as VMM
    14 from Transport import Transport
    14 from Transport import Transport
    15 
    15 
    16 MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
    16 MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
    17 
    17 
    18 class Domain:
    18 class Domain(object):
    19     """Class to manage e-mail domains."""
    19     """Class to manage e-mail domains."""
       
    20     __slots__ = ('_basedir','_domaindir','_id','_name','_transport','_dbh')
    20     def __init__(self, dbh, domainname, basedir=None, transport=None):
    21     def __init__(self, dbh, domainname, basedir=None, transport=None):
    21         """Creates a new Domain instance.
    22         """Creates a new Domain instance.
    22         
    23 
    23         Keyword arguments:
    24         Keyword arguments:
    24         dbh -- a pyPgSQL.PgSQL.connection
    25         dbh -- a pyPgSQL.PgSQL.connection
    25         domainname -- name of the domain (str)
    26         domainname -- name of the domain (str)
    26         transport -- default vmm.cfg/misc/transport  (str)
    27         transport -- default vmm.cfg/misc/transport  (str)
    27         """
    28         """
   104         else:
   105         else:
   105             return False
   106             return False
   106 
   107 
   107     def _chkDelete(self, delUser, delAlias):
   108     def _chkDelete(self, delUser, delAlias):
   108         """Checks dependencies for deletion.
   109         """Checks dependencies for deletion.
   109         
   110 
   110         Keyword arguments:
   111         Keyword arguments:
   111         delUser -- ignore available accounts (bool)
   112         delUser -- ignore available accounts (bool)
   112         delAlias -- ignore available aliases (bool)
   113         delAlias -- ignore available aliases (bool)
   113         """
   114         """
   114         if not delUser:
   115         if not delUser:
   274             for aname in anames:
   275             for aname in anames:
   275                 aliasdomains.append(aname[0])
   276                 aliasdomains.append(aname[0])
   276         return aliasdomains
   277         return aliasdomains
   277 
   278 
   278 def search(dbh, pattern=None, like=False):
   279 def search(dbh, pattern=None, like=False):
   279     if pattern is not None and like is False: 
   280     if pattern is not None and like is False:
   280         pattern = VMM.VirtualMailManager.chkDomainname(pattern)
   281         pattern = VMM.VirtualMailManager.chkDomainname(pattern)
   281     sql = 'SELECT gid, domainname, is_primary FROM domain_name'
   282     sql = 'SELECT gid, domainname, is_primary FROM domain_name'
   282     if pattern is None:
   283     if pattern is None:
   283         pass
   284         pass
   284     elif like:
   285     elif like: