-
Notifications
You must be signed in to change notification settings - Fork 878
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
add per-event-type support to add_subscriber_predicate #2537
Labels
Comments
The alternative of course is to simply handle the various event types inside each individual predicate instead of registering adapters. class ContextPredicate(object):
def __init__(self, val, config):
self.val = val
def __call__(self, event):
if isinstance(event, BeforeRender):
request = event['request']
else:
request = event.request This is what you currently have to do with no changes, and personally I find to be reasonable. I just opened this issue incase someone was offended by it and was looking for a way to improve things similar to the efforts in #1545. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As described in #1545 (comment) we should add
event=
to theconfig.add_subscriber_predicate
API to allow a different predicate per-event-type. This can be done with a simple adapter. We may be able to then register some default predicates for the builtin events.Note the biggest issue is that
BeforeRender
exposes therequest
asevent['request']
instead ofevent.request
which is a big reason an adapter-based api is necessary, but also because events have no required format.The text was updated successfully, but these errors were encountered: