From 46019ea781534cc7ea245265dc24890977dc2066 Mon Sep 17 00:00:00 2001 From: Michael Borisov Date: Tue, 17 Mar 2015 10:32:34 +0300 Subject: [PATCH] Using not deprecated method to import through strings --- omnibus/management/commands/omnibusd.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/omnibus/management/commands/omnibusd.py b/omnibus/management/commands/omnibusd.py index ad26b22..447e391 100644 --- a/omnibus/management/commands/omnibusd.py +++ b/omnibus/management/commands/omnibusd.py @@ -1,7 +1,12 @@ import logging from django.core.management.base import BaseCommand -from django.utils.module_loading import import_by_path + +try: + from django.utils.module_loading import import_string +except ImportError: + from django.utils.module_loading import import_by_path as import_string + from tornado import ioloop from ...pubsub import PubSub @@ -27,9 +32,9 @@ def handle(self, *args, **kwargs): pubsub.init_forwarder() # Get factories for connection and tornado webapp. - authenticator_factory = import_by_path(AUTHENTICATOR_FACTORY) - connection_factory = import_by_path(CONNECTION_FACTORY) - webapp_factory = import_by_path(WEBAPP_FACTORY) + authenticator_factory = import_string(AUTHENTICATOR_FACTORY) + connection_factory = import_string(CONNECTION_FACTORY) + webapp_factory = import_string(WEBAPP_FACTORY) # Create app and listen on SEVER_PORT app = webapp_factory(connection_factory(authenticator_factory(), pubsub))