Tutor plugin to hook Django signals

Hi!

I am playing with plugins in tutor, and I want to create a receiver for Django Signals. At this point everything is fine, the problem comes because I do not know where to connect my plugin entry point together with the hook.

I have created a python package, and I can install it using tutor into Open edX -it seems it works-, but I have a receiver to hook the Django signal -with some dummy logic- and I do not know how to install/setup into Open edX, or where it should be declared into Open edX… when I understand how it should be integrated I guess I will understand how to modify the plugin (patch, hook,…) I have just created.

Any help is welcomed, thanks!

As far as I understood your question, signals are setup in same way as we are doing in any simple django app in signal.py but If you want recieve some openedx event like course updated, published then event name is different otherwise for normal django model it’s same.

Let me know, I understood it correctly.

Where does your plugin entry point live? In a separate Python package? Is it a reusable Django application? It should; then I believe all you have to do is to add it to your INSTALLED_APPS in the LMS (or the CMS).

Yes, It is separate django app and add it as git submodule in edx and yes, put entry in installed_apps

Thanks both for the reply. My entry point is a hook in the init of LMS - Open edX where I have to decide how to modify the docker-image to add MySignalsApp. At this point, I have a tutor-plugin in one hand, and my-app to control Django Signals in another, how to put both together? Not sure how should I do it.

It looks like you are conflating two very different things here:

  1. You should use a Tutor patch to install your re-usable application in the Docker container. You should probably have a “openedx-dockerfile” patch with the following content: RUN pip install myreusableapp. Then you will need to re-build the openedx Docker image (tutor images build openedx).

  2. To add the reusable app to the LMS, you should add its name to the list of INSTALLED_APPS. To do so, you should again use a Tutor patch – probably the “openedx-lms-common-settings” patch, where you will write: INSTALLED_APPS.append("myreusableapp").

Does that make sense?

1 Like

Yep! It makes sense, thanks so much. I will come back with the results, I really appreciate your help (both)

Yes Make sense. Above link giving same detail to set custom code.

1 Like

To add the reusable app to the LMS, you should add its name to the list of INSTALLED_APPS. To do so, you should again use a Tutor patch – probably the “openedx-lms-common-settings” patch, where you will write: INSTALLED_APPS.append("myreusableapp") .

You can actually use the plugin system for this step to automatically install the djangoapp [1]. It also reference signals in the README, so it could maybe help you installing the signals (Many options are optional, as an example, here is an app that is installed only with the pip install step [2][3]).

Best.

[1] https://github.com/edx/edx-django-utils/tree/master/edx_django_utils/plugins
[2] https://github.com/eol-uchile/eol_completion/blob/master/setup.py#L17
[3] https://github.com/eol-uchile/eol_completion/blob/master/eol_completion/apps.py#L8

2 Likes

Yes, this is actually a better solution. Thanks for pointing this out. (Felipe is referring to the Open edX plugin system, totally unrelated with the Tutor plugin system)