6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 import threading |
9 import threading |
10 from os.path import join |
10 from os.path import join |
11 |
|
12 from time import mktime |
11 from time import mktime |
13 from datetime import datetime |
12 from datetime import datetime |
14 from base64 import b64decode |
13 from base64 import b64decode |
15 |
14 |
16 from Pyro.errors import PyroError, ConnectionClosedError |
15 from Pyro.errors import PyroError, ConnectionClosedError |
568 try: |
567 try: |
569 return self.source.eid2extid(eid, self._session) |
568 return self.source.eid2extid(eid, self._session) |
570 except UnknownEid: |
569 except UnknownEid: |
571 operator = self.current_operator |
570 operator = self.current_operator |
572 if operator is not None and operator != '=': |
571 if operator is not None and operator != '=': |
573 # deal with query like X eid > 12 |
572 # deal with query like "X eid > 12" |
574 # |
573 # |
575 # The problem is |
574 # The problem is that eid order in the external source may |
576 # that eid order in the external source may differ from the |
575 # differ from the local source |
577 # local source |
|
578 # |
576 # |
579 # So search for all eids from this |
577 # So search for all eids from this source matching the condition |
580 # source matching the condition locally and then to replace the |
578 # locally and then to replace the "> 12" branch by "IN (eids)" |
581 # > 12 branch by IN (eids) (XXX we may have to insert a huge |
579 # |
582 # number of eids...) |
580 # XXX we may have to insert a huge number of eids...) |
583 # planner so that |
|
584 sql = "SELECT extid FROM entities WHERE source='%s' AND type IN (%s) AND eid%s%s" |
581 sql = "SELECT extid FROM entities WHERE source='%s' AND type IN (%s) AND eid%s%s" |
585 etypes = ','.join("'%s'" % etype for etype in self.current_etypes) |
582 etypes = ','.join("'%s'" % etype for etype in self.current_etypes) |
586 cu = self._session.system_sql(sql % (self.source.uri, etypes, |
583 cu = self._session.system_sql(sql % (self.source.uri, etypes, |
587 operator, eid)) |
584 operator, eid)) |
588 # XXX buggy cu.rowcount which may be zero while there are some |
585 # XXX buggy cu.rowcount which may be zero while there are some |