I sometimes have need to do some initialization after Command.get_handle_params is called (so the command is in the correct state to execute with all the params set up) but before Command.handle is called. Basically, I want to do a context manager for some type of connection or something like that, and I can't just wrap Command.run because params won't be completely setup yet.
I first thought about just creating a handle_call method and having run call that method instead of handle but that seems like an extra method call for nothing.
Another approach would be to add a Command.handle_method_name property and then just have run use that (eg, getattr(self, self.handle_method_name)(*args, **kwargs))?
I sometimes have need to do some initialization after
Command.get_handle_params
is called (so the command is in the correct state to execute with all the params set up) but beforeCommand.handle
is called. Basically, I want to do a context manager for some type of connection or something like that, and I can't just wrapCommand.run
because params won't be completely setup yet.I first thought about just creating a
handle_call
method and havingrun
call that method instead ofhandle
but that seems like an extra method call for nothing.Another approach would be to add a
Command.handle_method_name
property and then just haverun
use that (eg,getattr(self, self.handle_method_name)(*args, **kwargs)
)?