equal
deleted
inserted
replaced
172 # ensure unicode |
172 # ensure unicode |
173 if context is not None: |
173 if context is not None: |
174 return unicode(req.pgettext(context, key)) |
174 return unicode(req.pgettext(context, key)) |
175 else: |
175 else: |
176 return unicode(req._(key)) |
176 return unicode(req._(key)) |
177 |
|
178 __builtins__['display_name'] = deprecated('[3.4] display_name should be imported from cubicweb.schema')(display_name) |
|
179 |
177 |
180 |
178 |
181 # Schema objects definition ################################################### |
179 # Schema objects definition ################################################### |
182 |
180 |
183 def ERSchema_display_name(self, req, form='', context=None): |
181 def ERSchema_display_name(self, req, form='', context=None): |
929 # start with a comma for bw compat,see below |
927 # start with a comma for bw compat,see below |
930 return ';' + ','.join(sorted(self.mainvars)) + ';' + self.expression |
928 return ';' + ','.join(sorted(self.mainvars)) + ';' + self.expression |
931 |
929 |
932 @classmethod |
930 @classmethod |
933 def deserialize(cls, value): |
931 def deserialize(cls, value): |
934 # XXX < 3.5.10 bw compat |
|
935 if not value.startswith(';'): |
|
936 return cls(value) |
|
937 _, mainvars, expression = value.split(';', 2) |
932 _, mainvars, expression = value.split(';', 2) |
938 return cls(expression, mainvars) |
933 return cls(expression, mainvars) |
939 |
934 |
940 def check(self, entity, rtype, value): |
935 def check(self, entity, rtype, value): |
941 """return true if the value satisfy the constraint, else false""" |
936 """return true if the value satisfy the constraint, else false""" |
971 """ |
966 """ |
972 |
967 |
973 def repo_check(self, session, eidfrom, rtype, eidto): |
968 def repo_check(self, session, eidfrom, rtype, eidto): |
974 """raise ValidationError if the relation doesn't satisfy the constraint |
969 """raise ValidationError if the relation doesn't satisfy the constraint |
975 """ |
970 """ |
976 pass # this is a vocabulary constraint, not enforce |
971 pass # this is a vocabulary constraint, not enforced |
977 |
972 |
978 |
973 |
979 class RepoEnforcedRQLConstraintMixIn(object): |
974 class RepoEnforcedRQLConstraintMixIn(object): |
980 |
975 |
981 def __init__(self, expression, mainvars=None, msg=None): |
976 def __init__(self, expression, mainvars=None, msg=None): |
986 # start with a semicolon for bw compat, see below |
981 # start with a semicolon for bw compat, see below |
987 return ';%s;%s\n%s' % (','.join(sorted(self.mainvars)), self.expression, |
982 return ';%s;%s\n%s' % (','.join(sorted(self.mainvars)), self.expression, |
988 self.msg or '') |
983 self.msg or '') |
989 |
984 |
990 def deserialize(cls, value): |
985 def deserialize(cls, value): |
991 # XXX < 3.5.10 bw compat |
|
992 if not value.startswith(';'): |
|
993 return cls(value) |
|
994 value, msg = value.split('\n', 1) |
986 value, msg = value.split('\n', 1) |
995 _, mainvars, expression = value.split(';', 2) |
987 _, mainvars, expression = value.split(';', 2) |
996 return cls(expression, mainvars, msg) |
988 return cls(expression, mainvars, msg) |
997 deserialize = classmethod(deserialize) |
989 deserialize = classmethod(deserialize) |
998 |
990 |