# HG changeset patch # User dwinter # Date 1372255322 -7200 # Node ID da890cb0fd047beb7e3db8551bea417a59e71fa7 # Parent 48c4a6f3b135e80153e1677971a478c3ad172f62 shows also context if wanted in getEntryFromPubman diff -r 48c4a6f3b135 -r da890cb0fd04 zopePubmanConnector.py --- a/zopePubmanConnector.py Wed Jun 26 15:10:35 2013 +0200 +++ b/zopePubmanConnector.py Wed Jun 26 16:02:02 2013 +0200 @@ -22,7 +22,8 @@ 'escidocMetadataRecords':"http://www.escidoc.de/schemas/metadatarecords/0.4", 'dc':'http://purl.org/dc/elements/1.1/', 'escidocComponents':'http://www.escidoc.de/schemas/components/0.8', - 'escidocItem':'http://www.escidoc.de/schemas/item/0.8' + 'escidocItem':'http://www.escidoc.de/schemas/item/0.8', + 'srel':'http://escidoc.de/core/01/structural-relations/', } @@ -280,7 +281,7 @@ return doctypes - def getEntryFromPubman(self,escidocid,extendedData=None): + def getEntryFromPubman(self,escidocid,extendedData=None,withContext=False): """get one entry""" @@ -294,8 +295,12 @@ ET.register_namespace("dcterms", "http://purl.org/dc/terms/") logging.debug(cn%escidocid) - root = ET.fromstring(content) - + try: + root = ET.fromstring(content) + except: + logging.error("zopePubmanConnector: cannot parse") + logging.error(content) + return "",'' citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" @@ -372,10 +377,20 @@ return citation.text,publicationTag.get('type'),bookID,linksIdentifier,linksLocator + + if citation is not None and withContext: + ctxPath=".//escidocItem:properties/srel:context" + ctx = item.find(ctxPath,ns) + + return citation.text,ctx.get('objid') + if citation is not None: return citation.text + + + return "",'' def pubmanConnectorURL(self):