14 from tempfile import mktemp |
14 from tempfile import mktemp |
15 from os.path import exists, join, basename, splitext |
15 from os.path import exists, join, basename, splitext |
16 |
16 |
17 from logilab.common.decorators import cached |
17 from logilab.common.decorators import cached |
18 from logilab.common.configuration import REQUIRED, read_old_config |
18 from logilab.common.configuration import REQUIRED, read_old_config |
|
19 |
|
20 from cubicweb import ConfigurationError |
19 |
21 |
20 |
22 |
21 def migration_files(config, toupgrade): |
23 def migration_files(config, toupgrade): |
22 """return an orderer list of path of scripts to execute to upgrade |
24 """return an orderer list of path of scripts to execute to upgrade |
23 an installed application according to installed cube and cubicweb versions |
25 an installed application according to installed cube and cubicweb versions |
326 for cube in cubes: |
328 for cube in cubes: |
327 assert cube in newcubes |
329 assert cube in newcubes |
328 self.config.add_cubes(newcubes) |
330 self.config.add_cubes(newcubes) |
329 return newcubes |
331 return newcubes |
330 |
332 |
331 def cmd_remove_cube(self, cube, removedeps=True): |
333 def cmd_remove_cube(self, cube, removedeps=False): |
332 if removedeps: |
334 if removedeps: |
333 toremove = self.config.expand_cubes([cube]) |
335 toremove = self.config.expand_cubes([cube]) |
334 else: |
336 else: |
335 toremove = (cube,) |
337 toremove = (cube,) |
336 origcubes = self.config._cubes |
338 origcubes = self.config._cubes |
337 basecubes = [c for c in origcubes if not c in toremove] |
339 basecubes = [c for c in origcubes if not c in toremove] |
338 self.config._cubes = tuple(self.config.expand_cubes(basecubes)) |
340 self.config._cubes = tuple(self.config.expand_cubes(basecubes)) |
339 removed = [p for p in origcubes if not p in self.config._cubes] |
341 removed = [p for p in origcubes if not p in self.config._cubes] |
340 assert cube in removed, \ |
342 if not cube in removed: |
341 "can't remove cube %s, used as a dependancy" % cube |
343 raise ConfigurationError("can't remove cube %s, " |
|
344 "used as a dependency" % cube) |
342 return removed |
345 return removed |
343 |
346 |
344 def rewrite_configuration(self): |
347 def rewrite_configuration(self): |
345 # import locally, show_diffs unavailable in gae environment |
348 # import locally, show_diffs unavailable in gae environment |
346 from cubicweb.toolsutils import show_diffs |
349 from cubicweb.toolsutils import show_diffs |