# HG changeset patch # User Sylvain Thénault # Date 1253111724 -7200 # Node ID db09803df8b2a15df9012abe8406598d06d7723f # Parent a6243d9585ba0f7e0166d24d40011057115bd154 fix cardinality integrity and security when setting use_email/primary_email diff -r a6243d9585ba -r db09803df8b2 sobjects/email.py --- a/sobjects/email.py Wed Sep 16 16:34:34 2009 +0200 +++ b/sobjects/email.py Wed Sep 16 16:35:24 2009 +0200 @@ -9,6 +9,7 @@ from cubicweb.server.hooksmanager import Hook from cubicweb.server.pool import PreCommitOperation +from cubicweb.server.repository import ensure_card_respected class SetUseEmailRelationOp(PreCommitOperation): """delay this operation to commit to avoid conflict with a late rql query @@ -26,6 +27,11 @@ def precommit_event(self): session = self.session if self.condition(): + # we've to handle cardinaly by ourselves since we're using unsafe_execute + # but use session.execute and not session.unsafe_execute to check we + # can change the relation + ensure_card_respected(session.execute, session, + self.fromeid, self.rtype, self.toeid) session.unsafe_execute( 'SET X %s Y WHERE X eid %%(x)s, Y eid %%(y)s' % self.rtype, {'x': self.fromeid, 'y': self.toeid}, 'x')