From: David Wilemski Date: Sat, 2 Jul 2011 22:22:51 +0000 (-0400) Subject: Used tornado.util.import_object X-Git-Tag: v2.1.0~134^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f41d05463f641cf40f355ed7e147f2ea0837211;p=thirdparty%2Ftornado.git Used tornado.util.import_object --- 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]