# HG changeset patch # User Sylvain Thénault # Date 1249076840 -7200 # Node ID 598ac51cac048417b6037e887dff72fa961194bb # Parent c4f6a53884eccfa743042d81b2c4321c57002e8c [R hooks] use DONT_CHECK_RTYPES_ON_[ADD|DEL] don't compute rset if not necessary diff -r c4f6a53884ec -r 598ac51cac04 server/hooks.py --- a/server/hooks.py Fri Jul 31 23:46:59 2009 +0200 +++ b/server/hooks.py Fri Jul 31 23:47:20 2009 +0200 @@ -461,14 +461,14 @@ def precommit_event(self): session = self.session entity = self.entity - rset = session.execute('Any S WHERE ET initial_state S, ET name %(name)s', - {'name': str(entity.e_schema)}) # if there is an initial state and the entity's state is not set, # use the initial state as a default state pendingeids = session.transaction_data.get('pendingeids', ()) - if rset and not entity.eid in pendingeids and not entity.in_state: - session.unsafe_execute('SET X in_state S WHERE X eid %(x)s, S eid %(s)s', - {'x' : entity.eid, 's' : rset[0][0]}, 'x') + if not entity.eid in pendingeids and not entity.in_state: + rset = session.execute('Any S WHERE ET initial_state S, ET name %(name)s', + {'name': entity.id}) + if rset: + session.add_relation(entity.eid, 'in_state', rset[0][0]) def set_initial_state_after_add(session, entity):