VirtualMailManager/Domain.py
changeset 35 22cc616aef61
parent 34 6d74e20c5b3b
child 43 92a6132940f5
--- a/VirtualMailManager/Domain.py	Sun May 18 04:51:12 2008 +0000
+++ b/VirtualMailManager/Domain.py	Sun May 25 03:42:42 2008 +0000
@@ -244,3 +244,18 @@
             for alias in addresses:
                 aliases.append(alias[0])
         return aliases
+
+def search(dbh, pattern=None, like=False):
+    sql = 'SELECT domainname FROM domains'
+    if pattern is None:
+        pass
+    elif like:
+        sql += " WHERE domainname LIKE '%s'" % pattern
+    else:
+        sql += " WHERE domainname = '%s'" % pattern
+    sql += ' ORDER BY domainname'
+    dbc = dbh.cursor()
+    dbc.execute(sql)
+    domains = dbc.fetchall()
+    dbc.close()
+    return domains