VMM/Domain: search() small code cleanups. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Mon, 05 Apr 2010 15:04:55 +0000
branchv0.6.x
changeset 242 496099847480
parent 241 2493453f2c10
child 243 30aaf2bc079c
VMM/Domain: search() small code cleanups.
VirtualMailManager/Domain.py
--- a/VirtualMailManager/Domain.py	Mon Apr 05 14:54:53 2010 +0000
+++ b/VirtualMailManager/Domain.py	Mon Apr 05 15:04:55 2010 +0000
@@ -340,15 +340,14 @@
     `like` : bool
       should be `True` when *pattern* starts/ends with a "%" sign
     """
-    if pattern is not None and like is False:
+    if pattern and not like:
         pattern = check_domainname(pattern)
     sql = 'SELECT gid, domainname, is_primary FROM domain_name'
-    if pattern is None:
-        pass
-    elif like:
-        sql += " WHERE domainname LIKE '%s'" % pattern
-    else:
-        sql += " WHERE domainname = '%s'" % pattern
+    if pattern:
+        if like:
+            sql += " WHERE domainname LIKE '%s'" % pattern
+        else:
+            sql += " WHERE domainname = '%s'" % pattern
     sql += ' ORDER BY is_primary DESC, domainname'
     dbc = dbh.cursor()
     dbc.execute(sql)