21 |
21 |
22 import urllib2 |
22 import urllib2 |
23 import StringIO |
23 import StringIO |
24 from os.path import exists |
24 from os.path import exists |
25 from datetime import datetime, timedelta |
25 from datetime import datetime, timedelta |
26 from base64 import b64decode |
|
27 from cookielib import CookieJar |
26 from cookielib import CookieJar |
28 import urlparse |
27 import urlparse |
29 from lxml import etree |
28 from lxml import etree |
30 |
29 |
31 from cubicweb import RegistryNotFound, ObjectNotFound, ValidationError, UnknownEid |
30 from cubicweb import RegistryNotFound, ObjectNotFound, ValidationError, UnknownEid |
280 |
279 |
281 def source_cwuris(self, cnx): |
280 def source_cwuris(self, cnx): |
282 sql = ('SELECT extid, eid, type FROM entities, cw_source_relation ' |
281 sql = ('SELECT extid, eid, type FROM entities, cw_source_relation ' |
283 'WHERE entities.eid=cw_source_relation.eid_from ' |
282 'WHERE entities.eid=cw_source_relation.eid_from ' |
284 'AND cw_source_relation.eid_to=%s' % self.eid) |
283 'AND cw_source_relation.eid_to=%s' % self.eid) |
285 return dict((b64decode(uri), (eid, type)) |
284 return dict((self.decode_extid(uri), (eid, type)) |
286 for uri, eid, type in cnx.system_sql(sql).fetchall()) |
285 for uri, eid, type in cnx.system_sql(sql).fetchall()) |
287 |
286 |
288 def init_import_log(self, cnx, **kwargs): |
287 def init_import_log(self, cnx, **kwargs): |
289 dataimport = cnx.create_entity('CWDataImport', cw_import_of=self, |
288 dataimport = cnx.create_entity('CWDataImport', cw_import_of=self, |
290 start_timestamp=datetime.utcnow(), |
289 start_timestamp=datetime.utcnow(), |