Move event priority mechanics to get_hooks() to factor in contextual events
This commit is contained in:
parent
da1e87e335
commit
85af02ffe5
1 changed files with 2 additions and 5 deletions
|
@ -110,13 +110,10 @@ class EventHook(object):
|
||||||
|
|
||||||
if context == None:
|
if context == None:
|
||||||
self._hooks.append(callback)
|
self._hooks.append(callback)
|
||||||
hooks = self._hooks
|
|
||||||
else:
|
else:
|
||||||
if not context in self._context_hooks:
|
if not context in self._context_hooks:
|
||||||
self._context_hooks[context] = []
|
self._context_hooks[context] = []
|
||||||
self._context_hooks[context].append(callback)
|
self._context_hooks[context].append(callback)
|
||||||
hooks = self._context_hooks[context]
|
|
||||||
hooks.sort(key=lambda x: x.priority)
|
|
||||||
|
|
||||||
if replay and not self._stored_events == None:
|
if replay and not self._stored_events == None:
|
||||||
for kwargs in self._stored_events:
|
for kwargs in self._stored_events:
|
||||||
|
@ -223,5 +220,5 @@ class EventHook(object):
|
||||||
child.purge_context(context)
|
child.purge_context(context)
|
||||||
|
|
||||||
def get_hooks(self):
|
def get_hooks(self):
|
||||||
return self._hooks + list(itertools.chain.from_iterable(
|
return sorted(self._hooks + list(itertools.chain.from_iterable(
|
||||||
self._context_hooks.values()))
|
self._context_hooks.values())), key=lambda e: e.priority)
|
||||||
|
|
Loading…
Reference in a new issue