# HG changeset patch # User Sylvain Thénault # Date 1260258375 -3600 # Node ID f6c65e04704c3d0d1b07e3aad88abcdd5eaaf3cc # Parent 394f853bb653dc216ef627f76f4e70b05596726d# Parent 4edff8bce44b1cb76c8a4cf3e34b637b49c2b197 backport stable branch diff -r 394f853bb653 -r f6c65e04704c .hgtags --- a/.hgtags Mon Dec 07 19:14:49 2009 +0100 +++ b/.hgtags Tue Dec 08 08:46:15 2009 +0100 @@ -92,3 +92,5 @@ 7a96c0544c138a0c5f452e5b2428ce6e2b7cb378 cubicweb-debian-version-3.5.7-1 1677312fd8a3e8c0a5ae083e3104ca62b7c9a5bb cubicweb-version-3.5.9 d7f2d32340fb59753548ef29cbc1958ef3a55fc6 cubicweb-debian-version-3.5.9-1 +9b52725d8c534ba40877457b413077a10173bf88 cubicweb-version-3.5.10 +dfe2f245248c97bea3a29c8ecc6d293e25ff708e cubicweb-debian-version-3.5.10-1 diff -r 394f853bb653 -r f6c65e04704c cwconfig.py --- a/cwconfig.py Mon Dec 07 19:14:49 2009 +0100 +++ b/cwconfig.py Tue Dec 08 08:46:15 2009 +0100 @@ -331,6 +331,10 @@ def available_cubes(cls): cubes = set() for directory in cls.cubes_search_path(): + if not os.path.exists(directory): + self.error('unexistant directory in cubes search path: %s' + % directory) + continue for cube in os.listdir(directory): if isdir(join(directory, cube)) and not cube == 'shared': cubes.add(cube) diff -r 394f853bb653 -r f6c65e04704c entities/wfobjs.py --- a/entities/wfobjs.py Mon Dec 07 19:14:49 2009 +0100 +++ b/entities/wfobjs.py Tue Dec 08 08:46:15 2009 +0100 @@ -152,6 +152,20 @@ tr.add_exit_point(fromstate, tostate) return tr + def replace_state(self, todelstate, replacement): + """migration convenience method""" + if not hasattr(todelstate, 'eid'): + todelstate = self.state_by_name(todelstate) + if not hasattr(replacement, 'eid'): + replacement = self.state_by_name(replacement) + execute = self._cw.unsafe_execute + execute('SET X in_state S WHERE S eid %(s)s', {'s': todelstate.eid}, 's') + execute('SET X from_state NS WHERE X to_state OS, OS eid %(os)s, NS eid %(ns)s', + {'os': todelstate.eid, 'ns': newstate.eid}, 's') + execute('SET X to_state NS WHERE X to_state OS, OS eid %(os)s, NS eid %(ns)s', + {'os': todelstate.eid, 'ns': newstate.eid}, 's') + todelstate.delete() + class BaseTransition(AnyEntity): """customized class for abstract transition diff -r 394f853bb653 -r f6c65e04704c utils.py --- a/utils.py Mon Dec 07 19:14:49 2009 +0100 +++ b/utils.py Tue Dec 08 08:46:15 2009 +0100 @@ -411,7 +411,7 @@ elif isinstance(obj, pydatetime.time): return obj.strftime('%H:%M:%S') elif isinstance(obj, pydatetime.timedelta): - return '%10d.%s' % (obj.days, obj.seconds) + return (obj.days * 24 * 60 * 60) + obj.seconds elif isinstance(obj, decimal.Decimal): return float(obj) try: