#1095 Fix circular dependency between module_build_service.__init__ and module_build_service.backports.
Merged 5 years ago by mprahl. Opened 5 years ago by jkaluza.
jkaluza/fm-orchestrator backports-circular-dep  into  master

@@ -24,7 +24,7 @@ 

  from flask.json import dumps

  from flask import request

  

- from module_build_service import app

+ import module_build_service

  

  

  def jsonify(*args, **kwargs):
@@ -35,7 +35,7 @@ 

      indent = None

      separators = (',', ':')

  

-     if app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:

+     if module_build_service.app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:

          indent = 2

          separators = (', ', ': ')

  
@@ -50,7 +50,7 @@ 

  

      # Note that we add '\n' to end of response

      # (see https://github.com/mitsuhiko/flask/pull/1262)

-     rv = app.response_class(

+     rv = module_build_service.app.response_class(

          (dumps(data, indent=indent, separators=separators), '\n'),

          mimetype='application/json')

      return rv

This fixes issues with calling 'python module_build_service/manage.py' directly
from the MBS git repo as part of testing local module builds without installing
MBS.

The issue is that 'import pkg_resources' for some reason tries to load
module_build_service.backports before the module_build_service.app actually
exists. This results in traceback saying that module_build_service.app does
not exist.

This commit fixes this by importing whole module_build_service in backports.py.

Pull-Request has been merged by mprahl

5 years ago