changeset 8:ddd7e357e518

changed getPreprints to getPublicationsFromContext. returns simple list.
author casties
date Fri, 03 May 2013 18:21:56 +0200
parents 06befe15f66f
children 166482535b54
files zopePubmanConnector.py
diffstat 1 files changed, 13 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/zopePubmanConnector.py	Fri May 03 14:30:07 2013 +0200
+++ b/zopePubmanConnector.py	Fri May 03 18:21:56 2013 +0200
@@ -9,11 +9,7 @@
 
 from Globals import package_home
 import httplib2
-import urlparse
-import urllib
-import re
 import xml.etree.ElementTree as ET
-import json
 import logging
 
 
@@ -229,8 +225,7 @@
         return self.connectorString
     
     
-    
-    def getPreprintsFromContext(self,context,limit=None,publicationType=None):
+    def getPublicationsFromContext(self,context,limit=None,publicationType=None):
         """gibt alle publicationen des context, jeweils als tupel ("escidoc:id",METADATEN)
         
         METADATEN ist hierbei eine Map mit :
@@ -241,13 +236,9 @@
         "authors" --> [(NACHNAME,VORNAME]),..]
         "title"--> title
         "year" --> issued
-       
-            
         """
         h = httplib2.Http(cacheFolder)
         
-        
-        
         if publicationType is None:
             cn = self.connectorString+"cqlQuery=escidoc.context.objid=%22"+context+"%22&"
             #cn = self.connectorString+"cqlQuery=escidoc.objid=%22"+"escidoc:643455"+"%22&"
@@ -261,7 +252,6 @@
   
         logging.debug(cn)
         resp, content = h.request(cn)
-    
      
         ET.register_namespace("dcterms", "http://purl.org/dc/terms/")
 
@@ -299,13 +289,10 @@
             #  <publication:source type="series">
             #      <dc:title>Max-Planck-Institut für Wissenschaftsgeschichte : Preprint</dc:title>
             #      <escidoc:volume>437</escidoc:volume>
-  
-  
 
             src= citation.find(srcpath)
             vol = src.find(volumepath)
             
-            
             #get link to fulltext
             #<escidocComponents:component objid="escidoc:644183">
             #<escidocComponents:properties>
@@ -331,11 +318,8 @@
             else:
                 link =""
             
-            
             #<dcterms:abstract xml:lang="deu">Dieser Preprint versammelt eine Auswahl von Beiträgen zum Symposium zu Ehren von Hans-Jörg Rheinbergers 65. Geburtstag. Es fand am 24.1.2011 im Max-Planck-Institute für Wissenschaftsgeschichte statt und brachte Freunde, Studenten und Kollegen von Hans-Jörg Rheinberger zusammen.</dcterms:abstract>
             #<dcterms:abstract xml:lang="eng">In this preprint, a selection of contributions to the symposium in honor of Hans-Jörg Rheinberger’s 65th birthday is published. It took place on January 24, 2011 at the Max-Planck-Institute for the History of Science and assembled friends, students and colleagues of Hans-Jörg Rheinberger.</dcterms:abstract>
-              
-            
             
             abstracts = citation.findall(abstractpath)
             
@@ -344,8 +328,6 @@
                 
                 lang = abstract.get("{http://www.w3.org/XML/1998/namespace}lang")
                 abstractTexts[lang]=abstract.text
-
-            
                  
             authorsTags = citation.findall(creatorpath)
           
@@ -357,44 +339,31 @@
                 
                 authors.append((fn,gn))
                 
+            titleTag = citation.find(titlepath)
 
-            titleTag = citation.find(titlepath)
-            
-
-                
             if titleTag is not None:
                 title = titleTag.text
             else:
                 title=""
          
-          
             issuedTag = citation.find(issuedpath)
-            
-
                 
             if issuedTag is not None:
                 issued = issuedTag.text
             else:
                 issued=""
-         
-          
-            
-            ret.append((objId,{"citation":text.text,"volume":vol.text,
-                               "link":link,
-                               "abstracts":abstractTexts,
-                               "authors":authors,
-                               "title":title,
-                               "year":issued}))
             
-        
-        def cmpret(x,y): #sort by preprint number
-            try:
-                return -cmp(int(x[2]),int(y[2]))
-            except:
-                return 0
-            #return cmp(x[2],y[2])
-        
-        ret.sort(cmpret)
+            item = {"id":objId,
+                    "citation":text.text,
+                    "volume":vol.text,
+                    "link":link,
+                    "abstracts":abstractTexts,
+                    "authors":authors,
+                    "title":title,
+                    "year":issued}
+
+            ret.append(item)
+            
         return ret
     
     
@@ -412,7 +381,6 @@
     newObj=ZopePubmanConnector(id,title,pubmanURL)
 
     self._setObject(id,newObj)
-    
   
     if RESPONSE is not None:
         RESPONSE.redirect('manage_main')