I would like to create a handler for the course_published event. 

Based on the comments in the SignalHandler class:

class SignalHandler(object):
    """
    This class is to allow the modulestores to emit signals that can be 
caught
    by other parts of the Django application. If your app needs to do 
something
    every time a course is published (e.g. search indexing), you can listen 
for
    that event and kick off a celery task when it happens.
    To listen for a signal, do the following::
        from django.dispatch import receiver
        from celery.task import task
        from xmodule.modulestore.django import modulestore, SignalHandler
        @receiver(SignalHandler.course_published)
        def listen_for_course_publish(sender, course_key, **kwargs):
            do_my_expensive_update.delay(course_key)
        @task()
        def do_my_expensive_update(course_key):
            # ...
    Things to note:
    1. We receive using the Django Signals mechanism.
    2. The sender is going to be the class of the modulestore sending it.
    3. The names of your handler function's parameters *must* be "sender" 
and "course_key".
    4. Always have **kwargs in your signal handler, as new things may be 
added.
    5. The thing that listens for the signal lives in process, but should do
       almost no work. Its main job is to kick off the celery task that will
       do the actual work.
    """

I understand what the code should look like. What I don't understand is 
where this code should go. Do I need to create a new django app and install 
it or is there a simpler way?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"General Open edX discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to edx-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/edx-code/99527c71-1741-41e0-8733-995be8993873%40googlegroups.com.

Reply via email to