I have a dispatcher in which a dictionary contains keys and each key has a list of methods/functions to call.
operation_request_handlers = {
'permissionsVARVARVARVARGET': [jwtoken.validate, permission_query],
'permissionsVARVARVARVARPOST': [jwtoken.validate, permission_set],
'permissionsVARVARVARVARDELETE': [jwtoken.validate, permission_delete],
}
This works fine if the dispatch target is a function (i.e. permission_query, or if the target is a static method (i.e. jwtoken.validate
).
The problem is I can't work out how to dispatch in cases where jwtoken.validate
is not a static method.
As far as I understand it, I would first need to instantiate jwtoken
then call the validate
method on that instance. Is this right? How would I even instantiate the jwtoken
class given all I have is jwtoken.validate
?
UPDATE: many have commented thank you all. My current thinking is that I should restrict the valid dispatch targets to callables.