src/pyams_utils/site.py
changeset 145 1a58b78a8f99
parent 72 9049384a2bd4
child 148 da830ed827eb
equal deleted inserted replaced
144:c9e3cfbbe4ad 145:1a58b78a8f99
   129             hooks.setSite(application)
   129             hooks.setSite(application)
   130             annotations = IAnnotations(application)
   130             annotations = IAnnotations(application)
   131             generations = annotations.get(SITE_GENERATIONS_KEY)
   131             generations = annotations.get(SITE_GENERATIONS_KEY)
   132             if generations is None:
   132             if generations is None:
   133                 generations = annotations[SITE_GENERATIONS_KEY] = PersistentDict()
   133                 generations = annotations[SITE_GENERATIONS_KEY] = PersistentDict()
   134             for name, utility in get_utilities_for(ISiteGenerations):
   134             for name, utility in sorted(get_utilities_for(ISiteGenerations),
       
   135                                         key=lambda x: x[1].order):
   135                 if not name:
   136                 if not name:
   136                     name = '.'.join((utility.__module__, utility.__class__.__name__))
   137                     name = '.'.join((utility.__module__, utility.__class__.__name__))
   137                 current = generations.get(name)
   138                 current = generations.get(name)
   138                 if (not current) or (current < utility.generation):
   139                 if not current:
       
   140                     print("Upgrading {0} to generation {1}...".format(name, utility.generation))
       
   141                 elif current < utility.generation:
   139                     print("Upgrading {0} from generation {1} to {2}...".format(name, current, utility.generation))
   142                     print("Upgrading {0} from generation {1} to {2}...".format(name, current, utility.generation))
   140                 utility.evolve(application, current)
   143                 utility.evolve(application, current)
   141                 generations[name] = utility.generation
   144                 generations[name] = utility.generation
   142         finally:
   145         finally:
   143             hooks.setSite(None)
   146             hooks.setSite(None)