Closed gainskills closed 3 years ago
I don't think this solution works, because the only way to cust_run_post_send
and cust_run_post_receive
is to fork the repo and define it in the class which defeats the purpose of this change.
One approach could be:
CUSTOM_RUN_POST_SEND = "path_to_func.cust_post_send"
if pyas2_settings.CUSTOM_RUN_POST_SEND:
pyas2_settings.CUSTOM_RUN_POST_SEND(message)
else:
run_post_send(message)
I don't think this solution works, because the only way to
cust_run_post_send
andcust_run_post_receive
is to fork the repo and define it in the class which defeats the purpose of this change.One approach could be:
- Define a setting like
CUSTOM_RUN_POST_SEND = "path_to_func.cust_post_send"
- Load the function in pyas2.settings
- Call the custom function if set:
if pyas2_settings.CUSTOM_RUN_POST_SEND: pyas2_settings.CUSTOM_RUN_POST_SEND(message) else: run_post_send(message)
@abhishek-ram thanks for your comment. I did a test before I post the PR, it works for me.
I also agree with your suggestion about having a setting to link functions for integration.
But, with the dependency, could you please suggest how to handle the dependency?
Thanks,
I know it works but I meant not working from a usability stand point.
What do you mean by dependency, can you elaborate?
Basically in the settings file of your django project you would define something like
PYAS2 = {
"CUSTOM_RUN_POST_SEND": "path_to_func.cust_post_send"
}
and in the pyas2.settings
module you would load it like so:
from django.utils.module_loading import import_string
CUSTOM_RUN_POST_SEND = APP_SETTINGS.get("CUSTOM_RUN_POST_SEND")
if CUSTOM_RUN_POST_SEND:
CUSTOM_RUN_POST_SEND = import_string(CUSTOM_RUN_POST_SEND)
You can then use CUSTOM_RUN_POST_SEND
wherever post send is called and call this function instead.
Basically in the settings file of your django project you would define something like
PYAS2 = { "CUSTOM_RUN_POST_SEND": "path_to_func.cust_post_send" }
and in the
pyas2.settings
module you would load it like so:from django.utils.module_loading import import_string CUSTOM_RUN_POST_SEND = APP_SETTINGS.get("CUSTOM_RUN_POST_SEND") if CUSTOM_RUN_POST_SEND: CUSTOM_RUN_POST_SEND = import_string(CUSTOM_RUN_POST_SEND)
You can then use
CUSTOM_RUN_POST_SEND
wherever post send is called and call this function instead.
Thanks for sharing this. Could you please roll the change out?
Thanks,
extend utils run_post_send/run_post_receive for integration (it only supports external command, right now could do with utils cust_run_post_send/cust_run_post_receive