Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handlers channels gathering #210

Open
apollo13 opened this issue Jan 22, 2017 · 1 comment
Open

Improve handlers channels gathering #210

apollo13 opened this issue Jan 22, 2017 · 1 comment

Comments

@apollo13
Copy link
Contributor

apollo13 commented Jan 22, 2017

According to:

# XXX: Why do we care about the event handler's channel?
# This probably costs us performance for what?
# I've not ever had to rely on this in practice...

the handler_channel always falls back to the component channel which kinda makes sense to "scope" them by default.

What about instead of doing that while getting the handlers, do that on handler registration:

class HandlerMetaClass(type):
def __init__(cls, name, bases, ns):
super(HandlerMetaClass, cls).__init__(name, bases, ns)
callables = (x for x in ns.items() if isinstance(x[1], Callable))
for name, callable in callables:
if not (name.startswith("_") or hasattr(callable, "handler")):
setattr(cls, name, handler(name)(callable))

We do have access to the whole class namespace there…

EDIT:// We'd still need to take care of that in the handler decorator itself since users can manually apply it without a channel name…
EDIT2:// Actually it isn't so simple, this probably doesn't take subclasses etc into account which can change the channel name XD

@prologic
Copy link
Member

prologic commented Jan 23, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants