equal
deleted
inserted
replaced
287 else: |
287 else: |
288 sql += " WHERE domainname = '%s'" % pattern |
288 sql += " WHERE domainname = '%s'" % pattern |
289 sql += ' ORDER BY is_primary DESC, domainname' |
289 sql += ' ORDER BY is_primary DESC, domainname' |
290 dbc = dbh.cursor() |
290 dbc = dbh.cursor() |
291 dbc.execute(sql) |
291 dbc.execute(sql) |
292 doms = dbc.fetchall() |
292 result = dbc.fetchall() |
293 dbc.close() |
293 dbc.close() |
294 |
294 |
295 domdict = {} |
295 gids = [domain[0] for domain in result if domain[2]] |
296 order = [dom[0] for dom in doms if dom[2]] |
296 domains = {} |
297 if len(order) == 0: |
297 for gid, domain, is_primary in result: |
298 for dom in doms: |
|
299 if dom[0] not in order: |
|
300 order.append(dom[0]) |
|
301 for gid, dom, is_primary in doms: |
|
302 if is_primary: |
298 if is_primary: |
303 domdict[gid] = [dom] |
299 if not gid in domains: |
304 else: |
300 domains[gid] = [domain] |
305 try: |
301 else: |
306 domdict[gid].append(dom) |
302 domains[gid].insert(0, domain) |
307 except KeyError: |
303 else: |
308 domdict[gid] = [None, dom] |
304 if gid in gids: |
309 del doms |
305 if gid in domains: |
310 return order, domdict |
306 domains[gid].append(domain) |
311 |
307 else: |
|
308 domains[gid] = [domain] |
|
309 else: |
|
310 gids.append(gid) |
|
311 domains[gid] = [None, domain] |
|
312 return gids, domains |
|
313 |