def attach_app(self, subOptions): app = None fromAppOpts = subOptions.parent.get('appOpts', {}).get('app') if fromAppOpts is not None: app = fromAppOpts elif subOptions['app'] is not None: app = import_string(subOptions['app']) else: # no app nor app import path given, let's guess! files_in_cwd = os.listdir(os.getcwd()) if 'manage.py' in files_in_cwd: sys.path.insert(0, os.getcwd()) from txdevserver.django_helpers import get_django_app django_app = get_django_app('manage.py') if django_app is not None: app = django_app if app is None: app = NoResource("Couldn't find the app!") rv = LoggedWSGIResource(reactor, reactor.getThreadPool(), app, subOptions.get('log_data_factory')) self.app = rv
def __init__(self, options): super(DevServer, self).__init__() for url_part, static_path in options['static'].iteritems(): static_resource = File(static_path) self.putChild(url_part, static_resource) for url_part, resource_path in options['resources'].iteritems(): resource = import_string(resource_path) self.putChild(url_part, resource) logger_file = os.path.join(os.path.dirname(__file__), 'logger.html') logger_static = File(logger_file) self.putChild("log", logger_static) self.putChild("log_es", ESLogger) self.attach_app(options) # let's use the old autoreload module for now # self.reloader = LoopingCall(self.check_and_reload, options) # self.reloader.start(2, now=True) self._mtimes = {} self.logger = logging.getLogger('webapp.devserver')