VirtualMailManager/Domain.py
changeset 35 22cc616aef61
parent 34 6d74e20c5b3b
child 43 92a6132940f5
equal deleted inserted replaced
34:6d74e20c5b3b 35:22cc616aef61
   242         aliases = []
   242         aliases = []
   243         if len(addresses) > 0:
   243         if len(addresses) > 0:
   244             for alias in addresses:
   244             for alias in addresses:
   245                 aliases.append(alias[0])
   245                 aliases.append(alias[0])
   246         return aliases
   246         return aliases
       
   247 
       
   248 def search(dbh, pattern=None, like=False):
       
   249     sql = 'SELECT domainname FROM domains'
       
   250     if pattern is None:
       
   251         pass
       
   252     elif like:
       
   253         sql += " WHERE domainname LIKE '%s'" % pattern
       
   254     else:
       
   255         sql += " WHERE domainname = '%s'" % pattern
       
   256     sql += ' ORDER BY domainname'
       
   257     dbc = dbh.cursor()
       
   258     dbc.execute(sql)
       
   259     domains = dbc.fetchall()
       
   260     dbc.close()
       
   261     return domains