VirtualMailManager/Domain.py
branchv0.6.x
changeset 242 496099847480
parent 240 fb6336b25b8f
child 254 8aecc83a0d32
equal deleted inserted replaced
241:2493453f2c10 242:496099847480
   338     `pattern` : basestring
   338     `pattern` : basestring
   339       a (partial) domain name (starting and/or ending with a "%" sign)
   339       a (partial) domain name (starting and/or ending with a "%" sign)
   340     `like` : bool
   340     `like` : bool
   341       should be `True` when *pattern* starts/ends with a "%" sign
   341       should be `True` when *pattern* starts/ends with a "%" sign
   342     """
   342     """
   343     if pattern is not None and like is False:
   343     if pattern and not like:
   344         pattern = check_domainname(pattern)
   344         pattern = check_domainname(pattern)
   345     sql = 'SELECT gid, domainname, is_primary FROM domain_name'
   345     sql = 'SELECT gid, domainname, is_primary FROM domain_name'
   346     if pattern is None:
   346     if pattern:
   347         pass
   347         if like:
   348     elif like:
   348             sql += " WHERE domainname LIKE '%s'" % pattern
   349         sql += " WHERE domainname LIKE '%s'" % pattern
   349         else:
   350     else:
   350             sql += " WHERE domainname = '%s'" % pattern
   351         sql += " WHERE domainname = '%s'" % pattern
       
   352     sql += ' ORDER BY is_primary DESC, domainname'
   351     sql += ' ORDER BY is_primary DESC, domainname'
   353     dbc = dbh.cursor()
   352     dbc = dbh.cursor()
   354     dbc.execute(sql)
   353     dbc.execute(sql)
   355     result = dbc.fetchall()
   354     result = dbc.fetchall()
   356     dbc.close()
   355     dbc.close()