--- a/server/hooksmanager.py Wed Sep 02 10:23:38 2009 +0200
+++ b/server/hooksmanager.py Wed Sep 02 16:38:08 2009 +0200
@@ -273,12 +273,6 @@
from cubicweb.server.pool import PreCommitOperation
-class RQLPrecommitOperation(PreCommitOperation):
- def precommit_event(self):
- execute = self.session.unsafe_execute
- for rql in self.rqls:
- execute(*rql)
-
class PropagateSubjectRelationHook(Hook):
"""propagate permissions and nosy list when new entity are added"""
@@ -299,10 +293,10 @@
else:
assert rtype in self.object_relations
meid, seid = toeid, fromeid
- rql = 'SET E %s P WHERE X %s P, X eid %%(x)s, E eid %%(e)s, NOT E %s P'\
- % (self.rtype, self.rtype, self.rtype)
- rqls = [(rql, {'x': meid, 'e': seid}, ('x', 'e'))]
- RQLPrecommitOperation(session, rqls=rqls)
+ session.unsafe_execute(
+ 'SET E %s P WHERE X %s P, X eid %%(x)s, E eid %%(e)s, NOT E %s P'\
+ % (self.rtype, self.rtype, self.rtype),
+ {'x': meid, 'e': seid}, ('x', 'e'))
class PropagateSubjectRelationAddHook(Hook):
@@ -316,19 +310,17 @@
def call(self, session, fromeid, rtype, toeid):
eschema = self.schema.eschema(session.describe(fromeid)[0])
- rqls = []
+ execute = session.unsafe_execute
for rel in self.subject_relations:
if eschema.has_subject_relation(rel):
- rqls.append(('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
- 'X %s R, NOT R %s P' % (rtype, rel, rtype),
- {'x': fromeid, 'p': toeid}, 'x'))
+ execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
+ 'X %s R, NOT R %s P' % (rtype, rel, rtype),
+ {'x': fromeid, 'p': toeid}, 'x')
for rel in self.object_relations:
if eschema.has_object_relation(rel):
- rqls.append(('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
- 'R %s X, NOT R %s P' % (rtype, rel, rtype),
- {'x': fromeid, 'p': toeid}, 'x'))
- if rqls:
- RQLPrecommitOperation(session, rqls=rqls)
+ execute('SET R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
+ 'R %s X, NOT R %s P' % (rtype, rel, rtype),
+ {'x': fromeid, 'p': toeid}, 'x')
class PropagateSubjectRelationDelHook(Hook):
@@ -342,16 +334,14 @@
def call(self, session, fromeid, rtype, toeid):
eschema = self.schema.eschema(session.describe(fromeid)[0])
- rqls = []
+ execute = session.unsafe_execute
for rel in self.subject_relations:
if eschema.has_subject_relation(rel):
- rqls.append(('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
- 'X %s R' % (rtype, rel),
- {'x': fromeid, 'p': toeid}, 'x'))
+ execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
+ 'X %s R' % (rtype, rel),
+ {'x': fromeid, 'p': toeid}, 'x')
for rel in self.object_relations:
if eschema.has_object_relation(rel):
- rqls.append(('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
- 'R %s X' % (rtype, rel),
- {'x': fromeid, 'p': toeid}, 'x'))
- if rqls:
- RQLPrecommitOperation(session, rqls=rqls)
+ execute('DELETE R %s P WHERE X eid %%(x)s, P eid %%(p)s, '
+ 'R %s X' % (rtype, rel),
+ {'x': fromeid, 'p': toeid}, 'x')