# HG changeset patch # User Sylvain Thénault # Date 1319704682 -7200 # Node ID 9ac82788f67bad3af620f6c1a2afbf50d743e3f9 # Parent 98222e3bb804dee0ebf9fc9b618bb976a5810274 [schema, old instance] restore some pre 3.5.10 bw compat as some old instances may still have this, and add migration so we can remove it at some point diff -r 98222e3bb804 -r 9ac82788f67b misc/migration/3.14.0_Any.py --- a/misc/migration/3.14.0_Any.py Wed Oct 26 17:59:06 2011 +0200 +++ b/misc/migration/3.14.0_Any.py Thu Oct 27 10:38:02 2011 +0200 @@ -1,3 +1,13 @@ config['rql-cache-size'] = config['rql-cache-size'] * 10 add_entity_type('CWDataImport') + +from cubicweb.schema import CONSTRAINTS, guess_rrqlexpr_mainvars +for rqlcstr in rql('Any X,XT,XV WHERE X is CWConstraint, X cstrtype XT, X value XV,' + 'X cstrtype XT, XT name IN ("RQLUniqueConstraint","RQLConstraint","RQLVocabularyConstraint"),' + 'NOT X value ~= ";%"').entities(): + expression = rqlcstr.value + mainvars = guess_rrqlexpr_mainvars(expression) + yamscstr = CONSTRAINTS[rqlcstr.type](expression, mainvars) + rqlcstr.set_attributes(value=yamscstr.serialize()) + print 'updated', rqlcstr.type, rqlcstr.value diff -r 98222e3bb804 -r 9ac82788f67b schema.py --- a/schema.py Wed Oct 26 17:59:06 2011 +0200 +++ b/schema.py Thu Oct 27 10:38:02 2011 +0200 @@ -929,6 +929,9 @@ @classmethod def deserialize(cls, value): + # XXX < 3.5.10 bw compat + if not value.startswith(';'): + return cls(value) _, mainvars, expression = value.split(';', 2) return cls(expression, mainvars) @@ -983,6 +986,9 @@ self.msg or '') def deserialize(cls, value): + # XXX < 3.5.10 bw compat + if not value.startswith(';'): + return cls(value) value, msg = value.split('\n', 1) _, mainvars, expression = value.split(';', 2) return cls(expression, mainvars, msg)