# HG changeset patch # User dwinter # Date 1366996039 -7200 # Node ID 373e6610e290b1447d86af43f7580f037dcb40b6 initial diff -r 000000000000 -r 373e6610e290 .pydevproject --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.pydevproject Fri Apr 26 19:07:19 2013 +0200 @@ -0,0 +1,8 @@ + + + +/ZopePubmanConnector + +python 2.7 +pythonZope13 + diff -r 000000000000 -r 373e6610e290 .settings/org.eclipse.core.resources.prefs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.core.resources.prefs Fri Apr 26 19:07:19 2013 +0200 @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/zopePubmanConnector.py=utf-8 diff -r 000000000000 -r 373e6610e290 __init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/__init__.py Fri Apr 26 19:07:19 2013 +0200 @@ -0,0 +1,15 @@ +import zopePubmanConnector + +def initialize(context): + """initialize OSAS""" + + + context.registerClass( + zopePubmanConnector.ZopePubmanConnector, + constructors = ( + zopePubmanConnector.manage_addZopePubmanConnectorForm, + zopePubmanConnector.manage_addZopePubmanConnector + ) + ) + + diff -r 000000000000 -r 373e6610e290 zopePubmanConnector.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zopePubmanConnector.py Fri Apr 26 19:07:19 2013 +0200 @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- + +#Verbindet Zope mit pubman. + + +from OFS.SimpleItem import SimpleItem +from Products.PageTemplates.PageTemplateFile import PageTemplateFile +import os.path + +from Globals import package_home +import httplib2 +import urlparse +import urllib +import re +import xml.etree.ElementTree as ET +import json + +def zptFile(self, path, orphaned=False): + """returns a page template file from the product""" + if orphaned: + # unusual case + pt=PageTemplateFile(os.path.join(package_home(globals()), path)) + else: + + pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self) + return pt + +class ZopePubmanConnector(SimpleItem): + + + connectorString="http://pubman.mpiwg-berlin.mpg.de/search/SearchAndExport?" + connectorString+="cqlQuery=escidoc.any-identifier=%22http://pubman.mpiwg-berlin.mpg.de/cone/persons/resource/303%22&" + connectorString+="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending" + + + meta_type="ZopePubmanConnector" + + manage_options= ({'label':'Main Config','action': 'changeMain'},) + SimpleItem.manage_options + + def __init__(self,id,title,pubmanURL): + self.id=id + self.title=title + self.pubmanURL=pubmanURL #URL einer pubman instance bzw. einer collection, falls nicht die default collection benutzt werden soll + + + + def changeMain(self,pubmanURL=None,title=None,REQUEST=None,RESPONSE=None): + """change main settings""" + if pubmanURL: + self.pubmanURL=pubmanURL + self.title=title + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + + else: + pt=zptFile(self, 'zpt/ChangeZopePubmanConnector.zpt') + return pt() + + + def getPublications(self,personID): + """get all publications der personID""" + h = httplib2.Http() + resp, content = h.request(self.connectorString) + ET.register_namespace("dcterms", "http://purl.org/dc/terms/") + + root = ET.fromstring(content) + + citationxpath=".//{http://purl.org/dc/terms/}bibliographicCitation" + + citations=root.findall(citationxpath) + + ret=[] + + for citation in citations: + ret.append(citation.text) + + + + return ret + + def pubmanConnectorURL(self): + return self.connectorString + +def manage_addZopePubmanConnectorForm(self): + """Form for external Links""" + pt=zptFile(self, 'zpt/AddZopePubmanConnector.zpt') + return pt() + + +def manage_addZopePubmanConnector(self,id,title,pubmanURL,RESPONSE=None): + """Add an external Link""" + + newObj=ZopePubmanConnector(id,title,pubmanURL) + + self._setObject(id,newObj) + + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + \ No newline at end of file diff -r 000000000000 -r 373e6610e290 zpt/AddZopePubmanConnector.zpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/AddZopePubmanConnector.zpt Fri Apr 26 19:07:19 2013 +0200 @@ -0,0 +1,15 @@ +

Header

+

Add a new Ressource

+
+ + + + + + + +
ID:
Title:
url:
 e.g. http://127.0.0.1:8983/PubmanConnector/collection1, no SLASH "/" at the end
+

+
+

Footer

+ \ No newline at end of file diff -r 000000000000 -r 373e6610e290 zpt/ChangeZopePubmanConnector.zpt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zpt/ChangeZopePubmanConnector.zpt Fri Apr 26 19:07:19 2013 +0200 @@ -0,0 +1,15 @@ +

Header

+

Add a new Ressource

+
+ + + + + + +
Title:
url:
 e.g. http://127.0.0.1:8983/PubmanConnector/collection1, no SLASH "/" at the end
+

+
+ +

Footer

+ \ No newline at end of file