# HG changeset patch # User Pascal Volk # Date 1270479895 0 # Node ID 496099847480e9810744672d57832fe324e81fc1 # Parent 2493453f2c1019b442b82d5a04c88e9a82d15b2e VMM/Domain: search() small code cleanups. diff -r 2493453f2c10 -r 496099847480 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)