Load the converter class on demand

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-04-27 02:47:23 -04:00
parent 3fa08debe9
commit 799d47054e
9 changed files with 30 additions and 22 deletions
@@ -11,11 +11,12 @@ from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from mayan.apps.converter import (
converter_class, BaseTransformation, TransformationResize,
TransformationRotate, TransformationZoom
BaseTransformation, TransformationResize, TransformationRotate,
TransformationZoom
)
from mayan.apps.converter.literals import DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION
from mayan.apps.converter.models import Transformation
from mayan.apps.converter.utils import get_converter_class
from ..managers import DocumentPageCachedImage, DocumentPageManager
from ..settings import (
@@ -71,7 +72,7 @@ class DocumentPage(models.Model):
def detect_orientation(self):
with self.document_version.open() as file_object:
converter = converter_class(
converter = get_converter_class()(
file_object=file_object,
mime_type=self.document_version.mimetype
)
@@ -193,7 +194,7 @@ class DocumentPage(models.Model):
if not setting_disable_base_image_cache.value and storage_documentimagecache.exists(cache_filename):
logger.debug('Page cache file "%s" found', cache_filename)
converter = converter_class(
converter = get_converter_class()(
file_object=storage_documentimagecache.open(cache_filename)
)
@@ -202,7 +203,7 @@ class DocumentPage(models.Model):
logger.debug('Page cache file "%s" not found', cache_filename)
try:
converter = converter_class(
converter = get_converter_class()(
file_object=self.document_version.get_intermidiate_file()
)
converter.seek(page_number=self.page_number - 1)