Skip to content

Commit 4be2754

Browse files
committed
issue2551250: Fix sorting of detectors
.. even if there are two with the same name and priority (can happen if they are created in two different files).
1 parent 8ab14c5 commit 4be2754

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Fixed:
5858
- Fix final exception handler in roundup-server to send proper
5959
Content-Length header to the client. (John Rouillard)
6060
- Fix traceback if Origin header is missing. (John Rouillard)
61+
- issue2551250: Fix sorting of detectors even if there are two with the
62+
same name and priority (can happen if they are created in two
63+
different files).
6164

6265
Features:
6366

roundup/hyperdb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,9 @@ def __init__(self, db, classname, **properties):
11831183
db.addclass(self)
11841184

11851185
actions = "create set retire restore".split()
1186-
self.auditors = dict([(a, PrioList()) for a in actions])
1187-
self.reactors = dict([(a, PrioList()) for a in actions])
1186+
skey = lambda x: x[:2]
1187+
self.auditors = dict([(a, PrioList(key=skey)) for a in actions])
1188+
self.reactors = dict([(a, PrioList(key=skey)) for a in actions])
11881189

11891190
def __repr__(self):
11901191
"""Slightly more useful representation

roundup/support.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ class PrioList:
4141
... p.append(i)
4242
...
4343
>>> for k in p:
44-
... print k
44+
... print (k)
4545
...
4646
-1
4747
1
4848
5
4949
7
5050
5151
'''
52-
def __init__(self):
52+
def __init__(self, key=None):
5353
self.list = []
54+
self.key = key
5455
self.sorted = True
5556

5657
def append(self, item):
@@ -59,7 +60,7 @@ def append(self, item):
5960

6061
def __iter__(self):
6162
if not self.sorted:
62-
self.list.sort()
63+
self.list.sort(key=self.key)
6364
self.sorted = True
6465
return iter(self.list)
6566

0 commit comments

Comments
 (0)