From 3f41d05463f641cf40f355ed7e147f2ea0837211 Mon Sep 17 00:00:00 2001 From: David Wilemski Date: Sat, 2 Jul 2011 18:22:51 -0400 Subject: [PATCH] Used tornado.util.import_object --- tornado/web.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tornado/web.py b/tornado/web.py index ffcbfd1d0..a47c2943f 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -80,7 +80,7 @@ from tornado import locale from tornado import stack_context from tornado import template from tornado.escape import utf8, _unicode -from tornado.util import b, bytes_type +from tornado.util import b, bytes_type, import_object try: from io import BytesIO # python 3 @@ -1175,14 +1175,9 @@ class Application(object): handler = spec[1] if isinstance(handler, str): - # Lazy load the Module and instantiate the class + # import the Module and instantiate the class # Must be a fully qualified name (module.ClassName) - parts = handler.split('.') - handler = ".".join(parts[:-1]) # create module name - handler = __import__(handler) # import the module - for part in parts[1:]: - handler = getattr(handler, part) - # The class has now been loaded and we can continue + handler = import_object(handler) if len(spec) == 3: kwargs = spec[2] -- 2.47.2