# Path: rest_framework_tus/signals.py

# 
# Path: rest_framework_tus/settings.py
# TUS_SAVE_HANDLER_CLASS = \
#     REST_FRAMEWORK_TUS.get('SAVE_HANDLER_CLASS', 'rest_framework_tus.storage.DefaultSaveHandler')


from abc import ABCMeta, abstractmethod
from django.core.files import File
from six import with_metaclass
from django.utils.module_loading import import_string
from rest_framework_tus import signals
from .settings import TUS_SAVE_HANDLER_CLASS
# -*- coding: utf-8 -*-
from __future__ import unicode_literals






class AbstractUploadSaveHandler(with_metaclass(ABCMeta, object)):
    def __init__(self, upload):
        self.upload = upload

    @abstractmethod
    def handle_save(self):
        pass

    def run(self):
        # Trigger state change
        self.upload.start_saving()
        self.upload.save()

        # Initialize saving
        self.handle_save()

    def finish(self):
        # Trigger signal

# Path: rest_framework_tus/signals.py

# 
# Path: rest_framework_tus/settings.py
# TUS_SAVE_HANDLER_CLASS = \
#     REST_FRAMEWORK_TUS.get('SAVE_HANDLER_CLASS', 'rest_framework_tus.storage.DefaultSaveHandler')


# Path: rest_framework_tus/storage.py
from abc import ABCMeta, abstractmethod
from django.core.files import File
from six import with_metaclass
from django.utils.module_loading import import_string
from rest_framework_tus import signals
from .settings import TUS_SAVE_HANDLER_CLASS

# -*- coding: utf-8 -*-
from __future__ import unicode_literals






class AbstractUploadSaveHandler(with_metaclass(ABCMeta, object)):
    def __init__(self, upload):
        self.upload = upload

    @abstractmethod
    def handle_save(self):
        pass

    def run(self):
        # Trigger state change
        self.upload.start_saving()
        self.upload.save()

        # Initialize saving
        self.handle_save()

    def finish(self):
        # Trigger signal

        signals.saved.send(sender=self.__class__, instance=self)