server/session.py
changeset 5557 1a534c596bff
parent 5444 f7fdb5dd82f6
child 5707 3586d36d2a45
equal deleted inserted replaced
5556:9ab2b4c74baf 5557:1a534c596bff
   240     def _update_entity_rel_cache_add(self, eid, rtype, role, targeteid):
   240     def _update_entity_rel_cache_add(self, eid, rtype, role, targeteid):
   241         try:
   241         try:
   242             entity = self.entity_cache(eid)
   242             entity = self.entity_cache(eid)
   243         except KeyError:
   243         except KeyError:
   244             return
   244             return
   245         rcache = entity.relation_cached(rtype, role)
   245         rcache = entity.cw_relation_cached(rtype, role)
   246         if rcache is not None:
   246         if rcache is not None:
   247             rset, entities = rcache
   247             rset, entities = rcache
   248             rset = rset.copy()
   248             rset = rset.copy()
   249             entities = list(entities)
   249             entities = list(entities)
   250             rset.rows.append([targeteid])
   250             rset.rows.append([targeteid])
   256                 targetentity.cw_rset = rset
   256                 targetentity.cw_rset = rset
   257                 targetentity.cw_row = rset.rowcount
   257                 targetentity.cw_row = rset.rowcount
   258                 targetentity.cw_col = 0
   258                 targetentity.cw_col = 0
   259             rset.rowcount += 1
   259             rset.rowcount += 1
   260             entities.append(targetentity)
   260             entities.append(targetentity)
   261             entity._related_cache['%s_%s' % (rtype, role)] = (rset, tuple(entities))
   261             entity._cw_related_cache['%s_%s' % (rtype, role)] = (
       
   262                 rset, tuple(entities))
   262 
   263 
   263     def _update_entity_rel_cache_del(self, eid, rtype, role, targeteid):
   264     def _update_entity_rel_cache_del(self, eid, rtype, role, targeteid):
   264         try:
   265         try:
   265             entity = self.entity_cache(eid)
   266             entity = self.entity_cache(eid)
   266         except KeyError:
   267         except KeyError:
   267             return
   268             return
   268         rcache = entity.relation_cached(rtype, role)
   269         rcache = entity.cw_relation_cached(rtype, role)
   269         if rcache is not None:
   270         if rcache is not None:
   270             rset, entities = rcache
   271             rset, entities = rcache
   271             for idx, row in enumerate(rset.rows):
   272             for idx, row in enumerate(rset.rows):
   272                 if row[0] == targeteid:
   273                 if row[0] == targeteid:
   273                     break
   274                     break
   282             del rset.rows[idx]
   283             del rset.rows[idx]
   283             if isinstance(rset.description, list): # else description not set
   284             if isinstance(rset.description, list): # else description not set
   284                 del rset.description[idx]
   285                 del rset.description[idx]
   285             del entities[idx]
   286             del entities[idx]
   286             rset.rowcount -= 1
   287             rset.rowcount -= 1
   287             entity._related_cache['%s_%s' % (rtype, role)] = (rset, tuple(entities))
   288             entity._cw_related_cache['%s_%s' % (rtype, role)] = (
       
   289                 rset, tuple(entities))
   288 
   290 
   289     # resource accessors ######################################################
   291     # resource accessors ######################################################
   290 
   292 
   291     def system_sql(self, sql, args=None, rollback_on_failure=True):
   293     def system_sql(self, sql, args=None, rollback_on_failure=True):
   292         """return a sql cursor on the system database"""
   294         """return a sql cursor on the system database"""