# HG changeset patch # User dwinter # Date 1367583973 -7200 # Node ID 49abb91d6c6ac5b76f190ea7aed917d9bece238b # Parent 245294b18a1dbe9c5247073ae3db74b5bdbde606 getPreprints gibt nun hash mit metadate zurueck diff -r 245294b18a1d -r 49abb91d6c6a zopePubmanConnector.py --- a/zopePubmanConnector.py Tue Apr 30 20:32:50 2013 +0200 +++ b/zopePubmanConnector.py Fri May 03 14:26:13 2013 +0200 @@ -16,6 +16,9 @@ import json import logging + +cacheFolder ="/var/tmp/.cacheWWW" + def zptFile(self, path, orphaned=False): """returns a page template file from the product""" if orphaned: @@ -60,7 +63,7 @@ def getPublications(self,personID,limit=None,publicationType=None): """get all publications der personID""" - h = httplib2.Http() + h = httplib2.Http(cacheFolder) @@ -164,7 +167,7 @@ else: query="(%s)"%ctxquery - h = httplib2.Http() + h = httplib2.Http(cacheFolder) logging.debug(cn%query) resp, content = h.request(cn%query) @@ -201,7 +204,7 @@ """get one entry""" escidocid=escidocid.lstrip().strip() - h = httplib2.Http() + h = httplib2.Http(cacheFolder) cn = self.connectorString+"cqlQuery=escidoc.objid=%s&" cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" @@ -229,7 +232,7 @@ def getPreprintsFromContext(self,context,limit=None,publicationType=None): """get all publications des context""" - h = httplib2.Http() + h = httplib2.Http(cacheFolder) @@ -256,7 +259,14 @@ citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" abstractpath=".//{http://purl.org/dc/terms/}abstract" - + issuedpath=".//{http://purl.org/dc/terms/}issued" + + creatorpath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/publication}creator/{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}person" + familyNamepath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}family-name" + givenNamepath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}given-name" + + + titlepath=".//{http://purl.org/dc/elements/1.1/}title" objxpath=".//{http://www.escidoc.de/schemas/item/0.8}item" srcpath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/publication}source" @@ -322,21 +332,47 @@ lang = abstract.get("{http://www.w3.org/XML/1998/namespace}lang") abstractTexts[lang]=abstract.text - + - #if abstractDE is not None: - # abstactDEtext = abstractDE.text - #else: - # abstactDEtext = "" + + authorsTags = citation.findall(creatorpath) + + authors=[] + for author in authorsTags: + + gn= author.find(givenNamepath).text + fn= author.find(familyNamepath).text + + authors.append((fn,gn)) + + + titleTag = citation.find(titlepath) - # abstractEN = citation.find(abstractENpath) - # if abstractEN is not None: - # abstactENtext = abstractEN.text - # else: - # abstactENtext = "" - # + + + if titleTag is not None: + title = titleTag.text + else: + title="" + - ret.append((objId,text.text,vol.text,link,abstractTexts)) + 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