already a schema constraint
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 22 Sep 2009 15:02:53 +0200
changeset 65 0049b8d1375c
parent 64 1cefc6b8bb8f
child 66 82fefda182ea
already a schema constraint
hooks.py
--- a/hooks.py	Tue Sep 22 11:49:30 2009 +0200
+++ b/hooks.py	Tue Sep 22 15:02:53 2009 +0200
@@ -13,26 +13,6 @@
 from cubicweb.sobjects.notification import NotificationView
 
 
-class BeforeKeywordApplicationHook(Hook):
-    """
-    * when a keyword is applied to an entity, we make sure the entity
-      type is actually related to the classification the keyword is
-      included in
-    """
-
-    events = ('before_add_relation',)
-    accepts = ('applied_to',)
-
-    def call(self, session, fromeid, rtype, toeid):
-        # XXX this could be expressed as a constraint in the schema, no?
-        rset = session.execute('Any C WHERE C classifies ET, K included_in C, '
-                               'X is ET, X eid %(x)s, K eid %(k)s',
-                               {'x' : toeid, 'k' : fromeid})
-        if not rset:
-            msg = session._("this keyword can't be applied to this kind of entity")
-            raise ValidationError(toeid, {'applied_to': msg})
-
-
 class SetIncludedInRelationOp(PreCommitOperation):
     """delay this operation to commit to avoid conflict with a late rql query
     already setting the relation