9 import threading |
9 import threading |
10 from os.path import join |
10 from os.path import join |
11 |
11 |
12 from time import mktime |
12 from time import mktime |
13 from datetime import datetime |
13 from datetime import datetime |
|
14 from base64 import b64decode |
14 |
15 |
15 from Pyro.errors import PyroError, ConnectionClosedError |
16 from Pyro.errors import PyroError, ConnectionClosedError |
16 |
17 |
17 from logilab.common.configuration import REQUIRED |
18 from logilab.common.configuration import REQUIRED |
18 |
19 |
175 try: |
176 try: |
176 for etype, extid in modified: |
177 for etype, extid in modified: |
177 try: |
178 try: |
178 exturi = cnx.describe(extid)[1] |
179 exturi = cnx.describe(extid)[1] |
179 if exturi == 'system' or not exturi in repo.sources_by_uri: |
180 if exturi == 'system' or not exturi in repo.sources_by_uri: |
180 eid = self.extid2eid(extid, etype, session) |
181 eid = self.extid2eid(str(extid), etype, session) |
181 rset = session.eid_rset(eid, etype) |
182 rset = session.eid_rset(eid, etype) |
182 entity = rset.get_entity(0, 0) |
183 entity = rset.get_entity(0, 0) |
183 entity.complete(entity.e_schema.indexable_attributes()) |
184 entity.complete(entity.e_schema.indexable_attributes()) |
184 repo.index_entity(session, entity) |
185 repo.index_entity(session, entity) |
185 except: |
186 except: |
186 self.exception('while updating %s with external id %s of source %s', |
187 self.exception('while updating %s with external id %s of source %s', |
187 etype, extid, self.uri) |
188 etype, extid, self.uri) |
188 continue |
189 continue |
189 for etype, extid in deleted: |
190 for etype, extid in deleted: |
190 try: |
191 try: |
191 eid = self.extid2eid(extid, etype, session, insert=False) |
192 eid = self.extid2eid(str(extid), etype, session, |
|
193 insert=False) |
192 # entity has been deleted from external repository but is not known here |
194 # entity has been deleted from external repository but is not known here |
193 if eid is not None: |
195 if eid is not None: |
194 repo.delete_info(session, eid) |
196 repo.delete_info(session, eid) |
195 except: |
197 except: |
196 self.exception('while updating %s with external id %s of source %s', |
198 self.exception('while updating %s with external id %s of source %s', |
305 for colindex in needtranslation: |
307 for colindex in needtranslation: |
306 if row[colindex] is not None: # optional variable |
308 if row[colindex] is not None: # optional variable |
307 etype = descr[rowindex][colindex] |
309 etype = descr[rowindex][colindex] |
308 exttype, exturi, extid = cnx.describe(row[colindex]) |
310 exttype, exturi, extid = cnx.describe(row[colindex]) |
309 if exturi == 'system' or not exturi in self.repo.sources_by_uri: |
311 if exturi == 'system' or not exturi in self.repo.sources_by_uri: |
310 eid = self.extid2eid(row[colindex], etype, session) |
312 eid = self.extid2eid(str(row[colindex]), etype, |
|
313 session) |
311 row[colindex] = eid |
314 row[colindex] = eid |
312 else: |
315 else: |
313 # skip this row |
316 # skip this row |
314 del rows[rowindex] |
317 del rows[rowindex] |
315 del descr[rowindex] |
318 del descr[rowindex] |
492 if node.neged(strict=True): |
495 if node.neged(strict=True): |
493 return |
496 return |
494 # XXX what about optional relation or outer NOT EXISTS() |
497 # XXX what about optional relation or outer NOT EXISTS() |
495 raise |
498 raise |
496 except ReplaceByInOperator, ex: |
499 except ReplaceByInOperator, ex: |
497 rhs = 'IN (%s)' % ','.join(str(eid) for eid in ex.eids) |
500 rhs = 'IN (%s)' % ','.join(eid for eid in ex.eids) |
498 self.need_translation = False |
501 self.need_translation = False |
499 self.current_operator = None |
502 self.current_operator = None |
500 if node.optional in ('right', 'both'): |
503 if node.optional in ('right', 'both'): |
501 rhs += '?' |
504 rhs += '?' |
502 if restr is not None: |
505 if restr is not None: |