changeset 18:da890cb0fd04

shows also context if wanted in getEntryFromPubman
author dwinter
date Wed, 26 Jun 2013 16:02:02 +0200
parents 48c4a6f3b135
children 38ff05179d71
files zopePubmanConnector.py
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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):