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): |
333 def cmd_remove_cube(self, cube, removedeps=False): |
|
334 if removedeps: |
|
335 toremove = self.config.expand_cubes([cube]) |
|
336 else: |
|
337 toremove = (cube,) |
332 origcubes = self.config._cubes |
338 origcubes = self.config._cubes |
333 basecubes = list(origcubes) |
339 basecubes = [c for c in origcubes if not c in toremove] |
334 for pkg in self.config.expand_cubes([cube]): |
|
335 try: |
|
336 basecubes.remove(pkg) |
|
337 except ValueError: |
|
338 continue |
|
339 self.config._cubes = tuple(self.config.expand_cubes(basecubes)) |
340 self.config._cubes = tuple(self.config.expand_cubes(basecubes)) |
340 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] |
341 assert cube in removed, \ |
342 if not cube in removed: |
342 "can't remove cube %s, used as a dependancy" % cube |
343 raise ConfigurationError("can't remove cube %s, " |
|
344 "used as a dependency" % cube) |
343 return removed |
345 return removed |
344 |
346 |
345 def rewrite_configuration(self): |
347 def rewrite_configuration(self): |
346 # import locally, show_diffs unavailable in gae environment |
348 # import locally, show_diffs unavailable in gae environment |
347 from cubicweb.toolsutils import show_diffs |
349 from cubicweb.toolsutils import show_diffs |