server/hooks.py
branchstable
changeset 3693 92581287726f
parent 3689 deb13e88e037
child 3773 14fde27a70a2
equal deleted inserted replaced
3692:54aa8d13aab4 3693:92581287726f
    83 def setis_after_add_entity(session, entity):
    83 def setis_after_add_entity(session, entity):
    84     """create a new entity -> set is relation"""
    84     """create a new entity -> set is relation"""
    85     if hasattr(entity, '_cw_recreating'):
    85     if hasattr(entity, '_cw_recreating'):
    86         return
    86         return
    87     try:
    87     try:
    88         session.add_relation(entity.eid, 'is',
    88         #session.add_relation(entity.eid, 'is',
    89                              eschema_type_eid(session, entity.id))
    89         #                     eschema_type_eid(session, entity.id))
       
    90         session.system_sql('INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)'
       
    91                            % (entity.eid, eschema_type_eid(session, entity.id)))
    90     except IndexError:
    92     except IndexError:
    91         # during schema serialization, skip
    93         # during schema serialization, skip
    92         return
    94         return
    93     # XXX < 2.50 bw compat
    95     for etype in entity.e_schema.ancestors() + [entity.e_schema]:
    94     if not session.get_shared_data('do-not-insert-is_instance_of'):
    96         #session.add_relation(entity.eid, 'is_instance_of',
    95         for etype in entity.e_schema.ancestors() + [entity.e_schema]:
    97         #                     eschema_type_eid(session, etype))
    96             session.add_relation(entity.eid, 'is_instance_of',
    98         session.system_sql('INSERT INTO is_instance_of_relation(eid_from,eid_to) VALUES (%s,%s)'
    97                                  eschema_type_eid(session, etype))
    99                            % (entity.eid, eschema_type_eid(session, etype)))
    98 
   100 
    99 
   101 
   100 def setowner_after_add_user(session, entity):
   102 def setowner_after_add_user(session, entity):
   101     """when a user has been created, add owned_by relation on itself"""
   103     """when a user has been created, add owned_by relation on itself"""
   102     session.add_relation(entity.eid, 'owned_by', entity.eid)
   104     session.add_relation(entity.eid, 'owned_by', entity.eid)