Mercurial > hg > ZopePubmanConnector
annotate zopePubmanConnector.py @ 24:345dd913f520 default tip
new pubman
author | Dirk Wintergr?n <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 10 Jan 2014 12:43:43 +0100 |
parents | d24a8673d68e |
children |
rev | line source |
---|---|
0 | 1 # -*- coding: utf-8 -*- |
2 | |
3 #Verbindet Zope mit pubman. | |
4 | |
5 | |
6 from OFS.SimpleItem import SimpleItem | |
7 from Products.PageTemplates.PageTemplateFile import PageTemplateFile | |
8 import os.path | |
9 | |
10 from Globals import package_home | |
11 import httplib2 | |
12 import xml.etree.ElementTree as ET | |
1 | 13 import logging |
9 | 14 import time |
10 | 15 import unicodedata |
6 | 16 |
16 | 17 TIMEOUT=10 |
18 | |
6 | 19 cacheFolder ="/var/tmp/.cacheWWW" |
20 | |
14 | 21 ns = {'escidocMetadataProfile':"http://escidoc.mpg.de/metadataprofile/schema/0.1/", |
22 'escidocMetadataRecords':"http://www.escidoc.de/schemas/metadatarecords/0.4", | |
23 'dc':'http://purl.org/dc/elements/1.1/', | |
24 'escidocComponents':'http://www.escidoc.de/schemas/components/0.8', | |
18 | 25 'escidocItem':'http://www.escidoc.de/schemas/item/0.8', |
26 'srel':'http://escidoc.de/core/01/structural-relations/', | |
14 | 27 } |
28 | |
29 | |
30 | |
0 | 31 def zptFile(self, path, orphaned=False): |
32 """returns a page template file from the product""" | |
33 if orphaned: | |
34 # unusual case | |
35 pt=PageTemplateFile(os.path.join(package_home(globals()), path)) | |
36 else: | |
37 | |
38 pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self) | |
39 return pt | |
40 | |
41 class ZopePubmanConnector(SimpleItem): | |
42 | |
43 | |
24 | 44 #connectorString="http://pubman.mpiwg-berlin.mpg.de/search/SearchAndExport?" |
0 | 45 |
46 | |
47 meta_type="ZopePubmanConnector" | |
48 | |
49 manage_options= ({'label':'Main Config','action': 'changeMain'},) + SimpleItem.manage_options | |
50 | |
51 def __init__(self,id,title,pubmanURL): | |
52 self.id=id | |
53 self.title=title | |
54 self.pubmanURL=pubmanURL #URL einer pubman instance bzw. einer collection, falls nicht die default collection benutzt werden soll | |
55 | |
56 | |
57 | |
58 def changeMain(self,pubmanURL=None,title=None,REQUEST=None,RESPONSE=None): | |
59 """change main settings""" | |
60 if pubmanURL: | |
61 self.pubmanURL=pubmanURL | |
62 self.title=title | |
63 | |
64 if RESPONSE is not None: | |
65 RESPONSE.redirect('manage_main') | |
66 | |
67 | |
68 else: | |
69 pt=zptFile(self, 'zpt/ChangeZopePubmanConnector.zpt') | |
70 return pt() | |
71 | |
72 | |
2 | 73 def getPublications(self,personID,limit=None,publicationType=None): |
0 | 74 """get all publications der personID""" |
16 | 75 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
1 | 76 |
2 | 77 if publicationType is None: |
11 | 78 # cn = self.connectorString+"cqlQuery=escidoc.any-identifier=%22"+personID+"%22&" |
24 | 79 cn = self.pubmanURL+"cqlQuery=escidoc.publication.creator.person.identifier=%22"+personID+"%22&" |
2 | 80 else: |
11 | 81 #cn = self.connectorString+"cqlQuery=escidoc.any-identifier=%22"+personID+"%22" |
24 | 82 cn = self.pubmanURL+"cqlQuery=%28escidoc.publication.creator.person.identifier=%22"+personID+"%22%29" |
13
43849c9cc08b
Incomplete - # 74: More Link auf den pers?nlichne Homepages
dwinter
parents:
12
diff
changeset
|
83 cn +="%20and%28%20escidoc.publication.type=%22"+publicationType+"%22%29&" |
2 | 84 |
85 cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" | |
86 if limit: | |
87 cn+="&maximumRecords=%s"%limit | |
1 | 88 |
2 | 89 logging.debug(cn) |
22 | 90 try: |
91 resp, content = h.request(cn) | |
2 | 92 |
22 | 93 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") |
94 | |
95 root = ET.fromstring(content) | |
0 | 96 |
22 | 97 except Exception, e: |
98 logging.error("Error getting and parsing data from PubMan: %s"%e) | |
99 return [] | |
0 | 100 |
2 | 101 #<escidocItem:item objid="escidoc:630782" |
102 | |
0 | 103 citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" |
104 | |
2 | 105 objxpath=".//{http://www.escidoc.de/schemas/item/0.8}item" |
14 | 106 |
107 | |
108 | |
2 | 109 citations=root.findall(objxpath) |
14 | 110 logging.debug(len(citations)) |
0 | 111 ret=[] |
112 for citation in citations: | |
2 | 113 objId = citation.get('objid') |
14 | 114 |
2 | 115 text = citation.find(citationxpath) |
14 | 116 |
117 idTermPath =""".//escidocMetadataRecords:md-records/escidocMetadataRecords:md-record/escidocMetadataProfile:publication/dc:identifier""" | |
118 #idTermPath =".//{http://purl.org/dc/elements/1.1/}identifier" | |
119 | |
120 idterms = citation.findall(idTermPath,ns) | |
121 | |
122 linksIdentifier=[] | |
123 linksLocator=[] | |
124 | |
125 | |
126 bookID = None | |
127 | |
128 | |
129 for idterm in idterms: | |
130 if idterm.get("{http://www.w3.org/2001/XMLSchema-instance}type",'') in ['eterms:OTHER','eidt:OTHER']: ##suche nach bookID | |
131 logging.debug("zopePubmanConnector: %s"%idterm.text) | |
132 checkID =idterm.text.lstrip().rstrip() | |
133 if checkID.startswith("MPIWG-Book:"): | |
134 bookID = checkID | |
135 break | |
136 elif idterm.get("{http://www.w3.org/2001/XMLSchema-instance}type",'') in ['eterms:URI','eidt:URI']: | |
137 linksIdentifier.append(idterm.text.lstrip().rstrip()) | |
138 | |
139 | |
140 | |
141 | |
142 componentsPath =""".//escidocComponents:components[1]""" | |
143 | |
144 components=citation.findall(componentsPath,ns); | |
145 | |
146 for component in components: | |
147 cnt = component.find(".//escidocComponents:content",ns) | |
148 if cnt is not None: | |
149 link="" | |
150 title="" | |
151 type="" | |
152 for name,value in cnt.items(): | |
153 if name.endswith("href"): | |
154 link=value | |
155 elif name.endswith("title"): | |
156 title=value | |
157 elif name.endswith("storage"): | |
158 type=value | |
159 | |
160 linksLocator.append((title,link,type)) | |
161 | |
162 | |
163 | |
164 | |
165 ret.append((objId,text.text,bookID,linksIdentifier,linksLocator)) | |
0 | 166 |
167 | |
168 | |
169 return ret | |
170 | |
2 | 171 |
19 | 172 def search(self,values={},exact=False,limit=None,contexts=None,resultWithContext=False,sortKeys="escidoc.any-dates"): |
2 | 173 """search pubman |
174 @values map mit field->value | |
175 @return map mit escidocId -> XML-formatted snippeds | |
176 """ | |
177 | |
178 fieldToEscidoc={"title":"escidoc.any-title", | |
179 "author":"escidoc.publication.any.publication-creator-names", | |
10 | 180 "any":"escidoc.metadata"} |
2 | 181 |
182 | |
24 | 183 cn = self.pubmanURL+"cqlQuery=%s&" |
19 | 184 #cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" |
185 #cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.property.creation-date&sortOrder=descending" | |
186 cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys="+sortKeys+"&sortOrder=descending" | |
2 | 187 |
5 | 188 if limit: |
189 cn+="&maximumRecords=%s"%limit | |
2 | 190 |
191 querys = [] | |
192 for field in values.keys(): | |
193 | |
194 searchField = fieldToEscidoc.get(field,None) | |
195 if searchField is None: | |
196 logging.debug("search, don't know field: %s"%field) | |
197 continue | |
198 | |
199 value = values[field] | |
10 | 200 try: |
201 value=unicodedata.normalize('NFKD', value).encode('ASCII', 'ignore') | |
202 except: | |
203 value=unicodedata.normalize('NFKD', value.decode('utf-8')).encode('ASCII', 'ignore') | |
2 | 204 if value == '': |
205 continue | |
206 logging.debug("%s=%s"%(field,value)) | |
207 if not exact: | |
208 value=value+"*" | |
209 | |
210 querys.append("%s=%%22%s%%22"%(searchField,value)) | |
211 | |
10 | 212 query="%20AND%20".join(querys) |
5 | 213 |
214 if contexts: # einscbraenken auf contexte | |
215 | |
216 if isinstance(contexts, str): | |
217 contexts=[contexts] | |
218 | |
219 ctxquerys=[] | |
220 for context in contexts: | |
221 ctxquerys.append("escidoc.context.objid=%%22%s%%22"%(context)) | |
222 | |
10 | 223 ctxquery="%20OR%20".join(ctxquerys) |
5 | 224 |
225 if query!="": | |
10 | 226 query=query+"AND%%20(%s)"%ctxquery |
5 | 227 else: |
228 query="(%s)"%ctxquery | |
229 | |
12 | 230 try: |
16 | 231 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
12 | 232 logging.debug("search: "+cn%query) |
233 resp, content = h.request(cn%query) | |
234 except: | |
235 logging.error("Unable to get data from PubMan!") | |
236 return {} | |
2 | 237 |
238 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") | |
239 | |
3 | 240 try: |
241 root = ET.fromstring(content) | |
242 except: | |
243 logging.error("Couldn't parse content of:%s"%(cn%query)) | |
244 return {} | |
2 | 245 #<escidocItem:item objid="escidoc:630782" |
246 | |
247 citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" | |
248 | |
249 objxpath=".//{http://www.escidoc.de/schemas/item/0.8}item" | |
250 citations=root.findall(objxpath) | |
251 | |
252 ret={} | |
253 for citation in citations: | |
254 objId = citation.get('objid') | |
255 text = citation.find(citationxpath) | |
19 | 256 |
257 if resultWithContext: | |
258 ctxPath=".//escidocItem:properties/srel:context" | |
259 ctx = citation.find(ctxPath,ns) | |
260 ret[objId]=(text.text,ctx.get('objid')) | |
261 else: | |
262 ret[objId]=text.text | |
2 | 263 |
264 return ret | |
265 | |
11 | 266 |
267 def getEntriesFromPubman(self,escidocids): | |
2 | 268 |
11 | 269 doctypes={} |
270 for escidocid in escidocids: | |
271 | |
15 | 272 txt, type, bookID,linksIdentifier,linksLocator = self.getEntryFromPubman(escidocid.escidocid, True) |
11 | 273 |
274 if not doctypes.has_key(type): | |
275 doctypes[type]=[] | |
15 | 276 |
277 entry={} | |
278 entry['citation']= txt | |
279 entry['escidocId']= escidocid.escidocid | |
280 entry['bookId']=bookID | |
281 entry['linksIdentifier']=linksIdentifier | |
282 entry['linksLocator']=linksIdentifier | |
283 doctypes[type].append(entry) | |
11 | 284 |
285 | |
286 return doctypes | |
287 | |
288 | |
18 | 289 def getEntryFromPubman(self,escidocid,extendedData=None,withContext=False): |
4 | 290 """get one entry""" |
291 | |
14 | 292 |
293 | |
3 | 294 escidocid=escidocid.lstrip().strip() |
17 | 295 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
24 | 296 cn = self.pubmanURL+"cqlQuery=escidoc.objid=%s&" |
2 | 297 cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" |
23 | 298 content = None |
18 | 299 try: |
22 | 300 resp, content = h.request(cn%escidocid) |
301 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") | |
302 logging.debug(cn%escidocid) | |
18 | 303 root = ET.fromstring(content) |
304 except: | |
22 | 305 logging.error("zopePubmanConnector: cannot parse: %s"%content) |
23 | 306 return "","" |
2 | 307 |
308 citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" | |
309 | |
14 | 310 itempath = ".//escidocItem:item" |
17 | 311 |
14 | 312 |
313 item = root.find(itempath,ns) #get item | |
314 | |
17 | 315 if item is None: |
316 logging.error("pubman connector: cannot find %s"%escidocid) | |
317 return escidocid,"","","","" | |
318 | |
14 | 319 citation=item.find(citationxpath,ns) |
320 | |
321 | |
322 if citation is not None and extendedData is not None: | |
323 | |
324 linksIdentifier=[] | |
325 linksLocator=[] | |
326 | |
2 | 327 |
11 | 328 |
14 | 329 #get identifier |
330 idTermPath =""".//escidocMetadataRecords:md-records/escidocMetadataRecords:md-record/escidocMetadataProfile:publication/dc:identifier""" | |
331 #idTermPath =".//{http://purl.org/dc/elements/1.1/}identifier" | |
332 | |
333 idterms = item.findall(idTermPath,ns) | |
334 | |
335 bookID = None | |
336 logging.debug("zopePubmanConnector: %s"%idterms) | |
337 for idterm in idterms: | |
338 | |
339 if idterm.get("{http://www.w3.org/2001/XMLSchema-instance}type",'') in ['eterms:OTHER','eidt:OTHER']: ##suche nach bookID | |
340 logging.debug("zopePubmanConnector: %s"%idterm.text) | |
341 checkID =idterm.text.lstrip().rstrip() | |
342 if checkID.startswith("MPIWG-Book:"): | |
343 bookID = checkID | |
344 break | |
345 elif idterm.get("{http://www.w3.org/2001/XMLSchema-instance}type",'') in ['eterms:URI','eidt:URI']: | |
346 linksIdentifier.append(idterm.text.lstrip().rstrip()) | |
347 | |
348 | |
349 #get files and locators | |
350 componentsPath =""".//escidocComponents:components[1]""" | |
351 | |
352 components=item.findall(componentsPath,ns); | |
353 | |
354 for component in components: | |
355 cnt = component.find(".//escidocComponents:content",ns) | |
356 if cnt is not None: | |
357 link="" | |
358 title="" | |
359 type="" | |
360 for name,value in cnt.items(): | |
361 if name.endswith("href"): | |
362 link=value | |
363 elif name.endswith("title"): | |
364 title=value | |
365 elif name.endswith("storage"): | |
366 type=value | |
367 | |
368 linksLocator.append((title,link,type)) | |
369 | |
370 | |
371 | |
372 | |
373 | |
374 | |
375 | |
376 | |
377 | |
11 | 378 path = ".//escidocMetadataRecords:md-records/escidocMetadataRecords:md-record/escidocMetadataProfile:publication" |
14 | 379 publicationTag= item.find(path,ns); |
380 | |
381 return citation.text,publicationTag.get('type'),bookID,linksIdentifier,linksLocator | |
11 | 382 |
18 | 383 |
384 if citation is not None and withContext: | |
385 ctxPath=".//escidocItem:properties/srel:context" | |
386 ctx = item.find(ctxPath,ns) | |
387 | |
388 return citation.text,ctx.get('objid') | |
389 | |
2 | 390 if citation is not None: |
391 | |
392 return citation.text | |
11 | 393 |
18 | 394 |
395 | |
396 | |
11 | 397 return "",'' |
2 | 398 |
0 | 399 def pubmanConnectorURL(self): |
24 | 400 return self.pubmanURL |
4 | 401 |
402 | |
10 | 403 def getPublicationsFromContext(self,context,limit=None,publicationType=None,search=None): |
7 | 404 """gibt alle publicationen des context, jeweils als tupel ("escidoc:id",METADATEN) |
405 | |
406 METADATEN ist hierbei eine Map mit : | |
407 "citation" --> citation in der APA formatierung | |
408 "volume" --> volume | |
409 "link" --> dowloadlink | |
410 "abstracts" --> map mit deu/eng für den abstrakt | |
411 "authors" --> [(NACHNAME,VORNAME]),..] | |
412 "title"--> title | |
413 "year" --> issued | |
414 """ | |
16 | 415 h = httplib2.Http(cacheFolder,timeout=TIMEOUT) |
4 | 416 |
417 if publicationType is None: | |
24 | 418 cn = self.pubmanURL+"cqlQuery=(escidoc.context.objid=%22"+context+"%22" |
419 #cn = self.pubmanURL+"cqlQuery=escidoc.objid=%22"+"escidoc:643455"+"%22&" | |
4 | 420 else: |
24 | 421 cn = self.pubmanURL+"cqlQuery=(escidoc.context.objid=%22"+context+"%22" |
10 | 422 cn +="%20and%20escidoc.publication.type=%22"+publicationType+"%22" |
4 | 423 |
10 | 424 if search is not None and search != "": |
425 try: | |
426 search = unicodedata.normalize('NFKD', search).encode('ASCII', 'ignore') | |
427 except: | |
428 search = unicodedata.normalize('NFKD', search.decode('utf-8')).encode('ASCII', 'ignore') | |
429 cn+="%20and%20escidoc.metadata="+search+"" | |
430 | |
431 | |
432 cn +=")&exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" | |
4 | 433 if limit: |
434 cn+="&maximumRecords=%s"%limit | |
435 | |
9 | 436 startTime = time.time() |
12 | 437 try: |
438 logging.debug("getPublicationsFromContext: getting %s"%cn) | |
439 resp, content = h.request(cn) | |
440 logging.debug("getPublicationsFromContext: got data in %ss"%(time.time()-startTime)) | |
4 | 441 |
12 | 442 ET.register_namespace("dcterms", "http://purl.org/dc/terms/") |
4 | 443 |
12 | 444 root = ET.fromstring(content) |
445 | |
446 except Exception, e: | |
447 logging.error("Unable to read and parse data! %s"%e) | |
448 return [] | |
449 | |
4 | 450 #<escidocItem:item objid="escidoc:630782" |
451 | |
452 citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" | |
453 abstractpath=".//{http://purl.org/dc/terms/}abstract" | |
6 | 454 issuedpath=".//{http://purl.org/dc/terms/}issued" |
455 | |
456 creatorpath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/publication}creator/{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}person" | |
457 familyNamepath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}family-name" | |
458 givenNamepath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}given-name" | |
459 | |
460 | |
461 titlepath=".//{http://purl.org/dc/elements/1.1/}title" | |
4 | 462 |
463 objxpath=".//{http://www.escidoc.de/schemas/item/0.8}item" | |
464 srcpath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/publication}source" | |
465 volumepath=".//{http://escidoc.mpg.de/metadataprofile/schema/0.1/types}volume" | |
466 | |
20 | 467 linkspath=""".//{http://www.escidoc.de/schemas/components/0.8}component/{http://www.escidoc.de/schemas/components/0.8}content[@storage="internal-managed"]""" |
21
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
468 visibility=""".//{http://www.escidoc.de/schemas/components/0.8}component/{http://www.escidoc.de/schemas/components/0.8}properties/{http://escidoc.de/core/01/properties/}visibility""" |
20 | 469 #linkspath=""".//{http://www.escidoc.de/schemas/components/0.8}component/{http://www.escidoc.de/schemas/components/0.8}content[@storage="external-url"]""" |
4 | 470 #linkspath=".//{http://www.escidoc.de/schemas/components/0.8}component/{http://www.escidoc.de/schemas/components/0.8}content" |
471 citations=root.findall(objxpath) | |
472 | |
473 ret=[] | |
474 for citation in citations: | |
475 objId = citation.get('objid') | |
476 | |
477 text = citation.find(citationxpath) | |
478 | |
479 #Get volume = preprintID | |
480 # <publication:source type="series"> | |
481 # <dc:title>Max-Planck-Institut für Wissenschaftsgeschichte : Preprint</dc:title> | |
482 # <escidoc:volume>437</escidoc:volume> | |
483 | |
484 src= citation.find(srcpath) | |
485 vol = src.find(volumepath) | |
486 | |
487 #get link to fulltext | |
488 #<escidocComponents:component objid="escidoc:644183"> | |
489 #<escidocComponents:properties> | |
490 # <prop:creation-date>2013-04-29T09:00:01.100Z</prop:creation-date> | |
491 # <prop:valid-status>valid</prop:valid-status> | |
492 # <prop:visibility>public</prop:visibility> | |
493 # <prop:content-category>pre-print</prop:content-category> | |
494 # <prop:file-name>P437.PDF</prop:file-name> | |
495 # <prop:mime-type>application/pdf</prop:mime-type> | |
496 # <prop:checksum>d0ccdc62d6707d934e60e9839ffe30bf</prop:checksum> | |
497 # <prop:checksum-algorithm>MD5</prop:checksum-algorithm> | |
498 #</escidocComponents:properties> | |
499 #<escidocComponents:content xlink:type="simple" xlink:title="P437.PDF" storage="internal-managed" | |
500 # xlink:href="http://pubman.mpiwg-berlin.mpg.de/pubman/item/escidoc:643686:3/component/escidoc:644183/P437.PDF"/> | |
21
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
501 # |
4 | 502 |
21
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
503 vis= citation.find(visibility) |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
504 |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
505 visText="" |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
506 if vis is not None: |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
507 visText =vis.text |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
508 |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
509 |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
510 print vis |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
511 scr=None |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
512 |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
513 if visText != "private": |
3562adeaba8b
only show non private links in getPublicationsFromContext
dwinter
parents:
20
diff
changeset
|
514 src= citation.find(linkspath) |
4 | 515 if src is not None: |
516 | |
517 link=src.get("{http://www.w3.org/1999/xlink}href") | |
518 #logging.debug(src.attrib) | |
519 | |
520 else: | |
521 link ="" | |
522 | |
523 #<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> | |
524 #<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> | |
525 | |
526 abstracts = citation.findall(abstractpath) | |
527 | |
528 abstractTexts={} | |
529 for abstract in abstracts: | |
530 | |
531 lang = abstract.get("{http://www.w3.org/XML/1998/namespace}lang") | |
532 abstractTexts[lang]=abstract.text | |
6 | 533 |
534 authorsTags = citation.findall(creatorpath) | |
535 | |
536 authors=[] | |
537 for author in authorsTags: | |
538 | |
539 gn= author.find(givenNamepath).text | |
540 fn= author.find(familyNamepath).text | |
541 | |
542 authors.append((fn,gn)) | |
543 | |
8
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
544 titleTag = citation.find(titlepath) |
6 | 545 |
546 if titleTag is not None: | |
547 title = titleTag.text | |
548 else: | |
549 title="" | |
550 | |
551 issuedTag = citation.find(issuedpath) | |
552 | |
553 if issuedTag is not None: | |
554 issued = issuedTag.text | |
555 else: | |
556 issued="" | |
4 | 557 |
8
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
558 item = {"id":objId, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
559 "citation":text.text, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
560 "volume":vol.text, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
561 "link":link, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
562 "abstracts":abstractTexts, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
563 "authors":authors, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
564 "title":title, |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
565 "year":issued} |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
566 |
ddd7e357e518
changed getPreprints to getPublicationsFromContext. returns simple list.
casties
parents:
7
diff
changeset
|
567 ret.append(item) |
9 | 568 |
569 logging.debug("getPublicationsFromContext: done in %ss"%(time.time()-startTime)) | |
4 | 570 return ret |
571 | |
572 | |
573 | |
0 | 574 |
575 def manage_addZopePubmanConnectorForm(self): | |
576 """Form for external Links""" | |
577 pt=zptFile(self, 'zpt/AddZopePubmanConnector.zpt') | |
578 return pt() | |
579 | |
580 | |
581 def manage_addZopePubmanConnector(self,id,title,pubmanURL,RESPONSE=None): | |
582 """Add an external Link""" | |
583 | |
584 newObj=ZopePubmanConnector(id,title,pubmanURL) | |
585 | |
586 self._setObject(id,newObj) | |
587 | |
588 if RESPONSE is not None: | |
589 RESPONSE.redirect('manage_main') | |
17 | 590 |