Mercurial > hg > ZopePubmanConnector
comparison zopePubmanConnector.py @ 16:3e154b154b6f
timeouts
author | dwinter |
---|---|
date | Fri, 14 Jun 2013 12:27:01 +0200 |
parents | ca3084877394 |
children | 48c4a6f3b135 |
comparison
equal
deleted
inserted
replaced
15:ca3084877394 | 16:3e154b154b6f |
---|---|
11 import httplib2 | 11 import httplib2 |
12 import xml.etree.ElementTree as ET | 12 import xml.etree.ElementTree as ET |
13 import logging | 13 import logging |
14 import time | 14 import time |
15 import unicodedata | 15 import unicodedata |
16 | |
17 TIMEOUT=10 | |
16 | 18 |
17 cacheFolder ="/var/tmp/.cacheWWW" | 19 cacheFolder ="/var/tmp/.cacheWWW" |
18 | 20 |
19 ns = {'escidocMetadataProfile':"http://escidoc.mpg.de/metadataprofile/schema/0.1/", | 21 ns = {'escidocMetadataProfile':"http://escidoc.mpg.de/metadataprofile/schema/0.1/", |
20 'escidocMetadataRecords':"http://www.escidoc.de/schemas/metadatarecords/0.4", | 22 'escidocMetadataRecords':"http://www.escidoc.de/schemas/metadatarecords/0.4", |
67 return pt() | 69 return pt() |
68 | 70 |
69 | 71 |
70 def getPublications(self,personID,limit=None,publicationType=None): | 72 def getPublications(self,personID,limit=None,publicationType=None): |
71 """get all publications der personID""" | 73 """get all publications der personID""" |
72 h = httplib2.Http(cacheFolder) | 74 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
73 | 75 |
74 | 76 |
75 | 77 |
76 if publicationType is None: | 78 if publicationType is None: |
77 # cn = self.connectorString+"cqlQuery=escidoc.any-identifier=%22"+personID+"%22&" | 79 # cn = self.connectorString+"cqlQuery=escidoc.any-identifier=%22"+personID+"%22&" |
224 query=query+"AND%%20(%s)"%ctxquery | 226 query=query+"AND%%20(%s)"%ctxquery |
225 else: | 227 else: |
226 query="(%s)"%ctxquery | 228 query="(%s)"%ctxquery |
227 | 229 |
228 try: | 230 try: |
229 h = httplib2.Http(cacheFolder) | 231 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
230 logging.debug("search: "+cn%query) | 232 logging.debug("search: "+cn%query) |
231 resp, content = h.request(cn%query) | 233 resp, content = h.request(cn%query) |
232 except: | 234 except: |
233 logging.error("Unable to get data from PubMan!") | 235 logging.error("Unable to get data from PubMan!") |
234 return {} | 236 return {} |
282 """get one entry""" | 284 """get one entry""" |
283 | 285 |
284 | 286 |
285 | 287 |
286 escidocid=escidocid.lstrip().strip() | 288 escidocid=escidocid.lstrip().strip() |
287 h = httplib2.Http(cacheFolder) | 289 h = httplib2.Http(cacheFolder,timout=TIMEOUT) |
288 cn = self.connectorString+"cqlQuery=escidoc.objid=%s&" | 290 cn = self.connectorString+"cqlQuery=escidoc.objid=%s&" |
289 cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" | 291 cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" |
290 | 292 |
291 resp, content = h.request(cn%escidocid) | 293 resp, content = h.request(cn%escidocid) |
292 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") | 294 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") |
385 "abstracts" --> map mit deu/eng für den abstrakt | 387 "abstracts" --> map mit deu/eng für den abstrakt |
386 "authors" --> [(NACHNAME,VORNAME]),..] | 388 "authors" --> [(NACHNAME,VORNAME]),..] |
387 "title"--> title | 389 "title"--> title |
388 "year" --> issued | 390 "year" --> issued |
389 """ | 391 """ |
390 h = httplib2.Http(cacheFolder) | 392 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
391 | 393 |
392 if publicationType is None: | 394 if publicationType is None: |
393 cn = self.connectorString+"cqlQuery=(escidoc.context.objid=%22"+context+"%22" | 395 cn = self.connectorString+"cqlQuery=(escidoc.context.objid=%22"+context+"%22" |
394 #cn = self.connectorString+"cqlQuery=escidoc.objid=%22"+"escidoc:643455"+"%22&" | 396 #cn = self.connectorString+"cqlQuery=escidoc.objid=%22"+"escidoc:643455"+"%22&" |
395 else: | 397 else: |