There's a Django signal emitted whenever an item is deleted from a course. You should be able to listen for that with your own code without touching anything in core. You can see an example of listening for it here:
Keep in mind that catching the signal happens synchronously in the same transaction as the request to delete the item. If you're going to do anything that might fail or take a long time (like a POST over a network connection), you'll probably want to make "my_handler" spin off a celery task instead so that it can run in the background and not slow down the act of deletion. It might look something like this:
from django.dispatch import receiver
from xmodule.modulestore.django import SignalHandler
from lms import CELERY_APP
@receiver(SignalHandler.item_deleted)
def my_handler(**kwargs):
usage_key = kwargs.get('usage_key') # This is what identifies the unit that was deleted
user_id = kwargs.get('user_id') # This is the user who did the deleting
course_key = usage_key.course_key # The identifier for the course it was deleted from.
do_something_slow.apply_async(args=(usage_key,))
@CELERY_APP.task(name='mymodule.tasks.do_something_slow')
def do_something_slow(usage_key):
# Whatever slow operation you need to do.
I'm a little fuzzy on that celery syntax, but I think that's it. Hope that helps.
Take care.