#1177 Keep the database session alive when checking the base module modulemd
Merged 4 months ago by mprahl. Opened 4 months ago by mprahl.

@@ -384,6 +384,7 @@ 

              mmd = Modulemd.Module().new_from_string(self.modulemd)

              mmd.upgrade()

          except Exception:

+             log.exception('An error occurred while trying to parse the modulemd')

              raise ValueError("Invalid modulemd")

          return mmd

  

@@ -258,18 +258,19 @@ 

                  base_module_obj = models.ModuleBuild.get_build_from_nsvc(

                      session, base_module, bm_in_xmd['stream'], bm_in_xmd['version'],

                      bm_in_xmd['context'])

-             if not base_module_obj:

-                 continue

+                 if not base_module_obj:

+                     continue

  

-             # Default to using the base module's stream, but if the base module has disttag_marking

-             # set in the xmd, use that instead

-             try:

-                 marking = base_module_obj.mmd().get_xmd()['mbs']['disttag_marking']

-             # We must check for a KeyError because a Variant object doesn't support the `get` method

-             except KeyError:

-                 marking = base_module_obj.stream

-             base_module_marking = marking + '+'

-             break

+                 # Default to using the base module's stream, but if the base module has

+                 # disttag_marking set in the xmd, use that instead

+                 try:

+                     marking = base_module_obj.mmd().get_xmd()['mbs']['disttag_marking']

+                 # We must check for a KeyError because a Variant object doesn't support the `get`

+                 # method

+                 except KeyError:

+                     marking = base_module_obj.stream

+                 base_module_marking = marking + '+'

+                 break

          else:

              log.warning('Module build {0} does not buildrequire a base module ({1})'

                          .format(module_build.id, ' or '.join(conf.base_module_names)))

This just indents the code so that it's under the with statement that generates the database session.

Pull-Request has been merged by mprahl

4 months ago