# HG changeset patch # User Denis Laxalde , RĂ©mi Cardona # Date 1429695553 -7200 # Node ID f585add0fed9f289bfe990aa0807bab6dad0a549 # Parent 2350424585f8df1a648c16cc1a61b47658f1b59e [schema] Let RQLConstraint inherit from BaseRQLConstraint instead of RQLVocabularyConstraint There is apparently no reason for RQLConstraint to inherit from RQLVocabularyConstraint as it gets its `repo_check` method from `RepoEnforcedRQLConstraintMixIn` and RQLVocabularyConstraint (which inherits from BaseRQLConstraint) actually only overrides that method. So simplify inheritance by removing a useless level of indirection. Adjust cw_unrelated_rql accordingly, where it was that RQLConstraint inherited from RQLVocabularyConstraint. diff -r 2350424585f8 -r f585add0fed9 entity.py --- a/entity.py Tue Sep 08 06:48:48 2015 +0200 +++ b/entity.py Wed Apr 22 11:39:13 2015 +0200 @@ -1147,9 +1147,7 @@ self._cw.vreg.solutions(self._cw, select, args) # insert RQL expressions for schema constraints into the rql syntax tree if vocabconstraints: - # RQLConstraint is a subclass for RQLVocabularyConstraint, so they - # will be included as well - cstrcls = RQLVocabularyConstraint + cstrcls = (RQLVocabularyConstraint, RQLConstraint) else: cstrcls = RQLConstraint lt_infos = pruned_lt_info(self.e_schema, lt_infos or {}) diff -r 2350424585f8 -r f585add0fed9 schema.py --- a/schema.py Tue Sep 08 06:48:48 2015 +0200 +++ b/schema.py Wed Apr 22 11:39:13 2015 +0200 @@ -1257,7 +1257,7 @@ return _cw.execute(rql, args, build_descr=False) -class RQLConstraint(RepoEnforcedRQLConstraintMixIn, RQLVocabularyConstraint): +class RQLConstraint(RepoEnforcedRQLConstraintMixIn, BaseRQLConstraint): """the rql constraint is similar to the RQLVocabularyConstraint but are also enforced at the repository level """ diff -r 2350424585f8 -r f585add0fed9 test/unittest_schema.py --- a/test/unittest_schema.py Tue Sep 08 06:48:48 2015 +0200 +++ b/test/unittest_schema.py Wed Apr 22 11:39:13 2015 +0200 @@ -105,10 +105,9 @@ # # isinstance(cstr, RQLConstraint) # -> expected to return RQLConstraint instances but not - # RRQLVocabularyConstraint and QLUniqueConstraint + # RQLVocabularyConstraint and RQLUniqueConstraint self.assertFalse(issubclass(RQLUniqueConstraint, RQLVocabularyConstraint)) self.assertFalse(issubclass(RQLUniqueConstraint, RQLConstraint)) - self.assertTrue(issubclass(RQLConstraint, RQLVocabularyConstraint)) def test_entity_perms(self): self.assertEqual(eperson.get_groups('read'), set(('managers', 'users', 'guests')))