[schema] Let RQLConstraint inherit from BaseRQLConstraint instead of RQLVocabularyConstraint
authorDenis Laxalde <denis.laxalde@logilab.fr>, Rémi Cardona <remi.cardona@logilab.fr>
Wed, 22 Apr 2015 11:39:13 +0200
changeset 10833 f585add0fed9
parent 10832 2350424585f8
child 10834 c9321aedfbf9
[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.
entity.py
schema.py
test/unittest_schema.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 {})
--- 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
     """
--- 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')))