server/sources/pyrorql.py
branchstable
changeset 7815 2a164a9cf81c
parent 7697 ef50074a0314
child 7879 9aae456abab5
equal deleted inserted replaced
7814:1ec9fe1dfba9 7815:2a164a9cf81c
   224                     del self.support_relations[ertype]
   224                     del self.support_relations[ertype]
   225                     if ertype in self.cross_relations:
   225                     if ertype in self.cross_relations:
   226                         self.cross_relations.remove(ertype)
   226                         self.cross_relations.remove(ertype)
   227                 else:
   227                 else:
   228                     self.dont_cross_relations.remove(ertype)
   228                     self.dont_cross_relations.remove(ertype)
   229         except:
   229         except Exception:
   230             self.error('while updating mapping consequently to removal of %s',
   230             self.error('while updating mapping consequently to removal of %s',
   231                        schemacfg)
   231                        schemacfg)
   232 
   232 
   233     def local_eid(self, cnx, extid, session):
   233     def local_eid(self, cnx, extid, session):
   234         etype, dexturi, dextid = cnx.describe(extid)
   234         etype, dexturi, dextid = cnx.describe(extid)
   273                     if eid is not None:
   273                     if eid is not None:
   274                         rset = session.eid_rset(eid, etype)
   274                         rset = session.eid_rset(eid, etype)
   275                         entity = rset.get_entity(0, 0)
   275                         entity = rset.get_entity(0, 0)
   276                         entity.complete(entity.e_schema.indexable_attributes())
   276                         entity.complete(entity.e_schema.indexable_attributes())
   277                         source.index_entity(session, entity)
   277                         source.index_entity(session, entity)
   278                 except:
   278                 except Exception:
   279                     self.exception('while updating %s with external id %s of source %s',
   279                     self.exception('while updating %s with external id %s of source %s',
   280                                    etype, extid, self.uri)
   280                                    etype, extid, self.uri)
   281                     continue
   281                     continue
   282             for etype, extid in deleted:
   282             for etype, extid in deleted:
   283                 try:
   283                 try:
   286                     # entity has been deleted from external repository but is not known here
   286                     # entity has been deleted from external repository but is not known here
   287                     if eid is not None:
   287                     if eid is not None:
   288                         entity = session.entity_from_eid(eid, etype)
   288                         entity = session.entity_from_eid(eid, etype)
   289                         repo.delete_info(session, entity, self.uri, extid,
   289                         repo.delete_info(session, entity, self.uri, extid,
   290                                          scleanup=self.eid)
   290                                          scleanup=self.eid)
   291                 except:
   291                 except Exception:
   292                     self.exception('while updating %s with external id %s of source %s',
   292                     self.exception('while updating %s with external id %s of source %s',
   293                                    etype, extid, self.uri)
   293                                    etype, extid, self.uri)
   294                     continue
   294                     continue
   295             self.latest_retrieval = updatetime
   295             self.latest_retrieval = updatetime
   296             session.execute('SET X latest_retrieval %(date)s WHERE X eid %(x)s',
   296             session.execute('SET X latest_retrieval %(date)s WHERE X eid %(x)s',
   665 
   665 
   666     def process_eid_const(self, const):
   666     def process_eid_const(self, const):
   667         value = const.eval(self.kwargs)
   667         value = const.eval(self.kwargs)
   668         try:
   668         try:
   669             return None, self._const_var[value]
   669             return None, self._const_var[value]
   670         except:
   670         except Exception:
   671             var = self._varmaker.next()
   671             var = self._varmaker.next()
   672             self.need_translation = True
   672             self.need_translation = True
   673             restr = '%s eid %s' % (var, self.visit_constant(const))
   673             restr = '%s eid %s' % (var, self.visit_constant(const))
   674             self.need_translation = False
   674             self.need_translation = False
   675             self._const_var[value] = var
   675             self._const_var[value] = var