comparison zopePubmanConnector.py @ 18:da890cb0fd04

shows also context if wanted in getEntryFromPubman
author dwinter
date Wed, 26 Jun 2013 16:02:02 +0200
parents 48c4a6f3b135
children 38ff05179d71
comparison
equal deleted inserted replaced
17:48c4a6f3b135 18:da890cb0fd04
20 20
21 ns = {'escidocMetadataProfile':"http://escidoc.mpg.de/metadataprofile/schema/0.1/", 21 ns = {'escidocMetadataProfile':"http://escidoc.mpg.de/metadataprofile/schema/0.1/",
22 'escidocMetadataRecords':"http://www.escidoc.de/schemas/metadatarecords/0.4", 22 'escidocMetadataRecords':"http://www.escidoc.de/schemas/metadatarecords/0.4",
23 'dc':'http://purl.org/dc/elements/1.1/', 23 'dc':'http://purl.org/dc/elements/1.1/',
24 'escidocComponents':'http://www.escidoc.de/schemas/components/0.8', 24 'escidocComponents':'http://www.escidoc.de/schemas/components/0.8',
25 'escidocItem':'http://www.escidoc.de/schemas/item/0.8' 25 'escidocItem':'http://www.escidoc.de/schemas/item/0.8',
26 'srel':'http://escidoc.de/core/01/structural-relations/',
26 } 27 }
27 28
28 29
29 30
30 def zptFile(self, path, orphaned=False): 31 def zptFile(self, path, orphaned=False):
278 279
279 280
280 return doctypes 281 return doctypes
281 282
282 283
283 def getEntryFromPubman(self,escidocid,extendedData=None): 284 def getEntryFromPubman(self,escidocid,extendedData=None,withContext=False):
284 """get one entry""" 285 """get one entry"""
285 286
286 287
287 288
288 escidocid=escidocid.lstrip().strip() 289 escidocid=escidocid.lstrip().strip()
292 293
293 resp, content = h.request(cn%escidocid) 294 resp, content = h.request(cn%escidocid)
294 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") 295 ET.register_namespace("dcterms", "http://purl.org/dc/terms/")
295 logging.debug(cn%escidocid) 296 logging.debug(cn%escidocid)
296 297
297 root = ET.fromstring(content) 298 try:
298 299 root = ET.fromstring(content)
300 except:
301 logging.error("zopePubmanConnector: cannot parse")
302 logging.error(content)
303 return "",''
299 304
300 citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" 305 citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation"
301 306
302 itempath = ".//escidocItem:item" 307 itempath = ".//escidocItem:item"
303 308
370 path = ".//escidocMetadataRecords:md-records/escidocMetadataRecords:md-record/escidocMetadataProfile:publication" 375 path = ".//escidocMetadataRecords:md-records/escidocMetadataRecords:md-record/escidocMetadataProfile:publication"
371 publicationTag= item.find(path,ns); 376 publicationTag= item.find(path,ns);
372 377
373 return citation.text,publicationTag.get('type'),bookID,linksIdentifier,linksLocator 378 return citation.text,publicationTag.get('type'),bookID,linksIdentifier,linksLocator
374 379
380
381 if citation is not None and withContext:
382 ctxPath=".//escidocItem:properties/srel:context"
383 ctx = item.find(ctxPath,ns)
384
385 return citation.text,ctx.get('objid')
386
375 if citation is not None: 387 if citation is not None:
376 388
377 return citation.text 389 return citation.text
390
391
392
378 393
379 return "",'' 394 return "",''
380 395
381 def pubmanConnectorURL(self): 396 def pubmanConnectorURL(self):
382 return self.connectorString 397 return self.connectorString