changeset 0:373e6610e290

initial
author dwinter
date Fri, 26 Apr 2013 19:07:19 +0200
parents
children c6478f155400
files .pydevproject .settings/org.eclipse.core.resources.prefs __init__.py zopePubmanConnector.py zpt/AddZopePubmanConnector.zpt zpt/ChangeZopePubmanConnector.zpt
diffstat 6 files changed, 157 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.pydevproject	Fri Apr 26 19:07:19 2013 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?><pydev_project>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/ZopePubmanConnector</path>
+</pydev_pathproperty>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">pythonZope13</pydev_property>
+</pydev_project>
--- /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
--- /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
+          )
+        )
+
+
--- /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
--- /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 @@
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
+    <h2>Add a new Ressource</h2>
+    <form name="form" action="manage_addZopePubmanConnector">
+    <table> 
+    	<tr><td> ID: </td><td><input type="text" name="id" size=50></td></tr>
+      <tr><td> Title: </td><td><input type="text" name="title" size=50></td></tr>
+      <tr><td> url: </td><td><input type="text" name="pubmanURL" size=50></td></tr>
+      <tr><td>&nbsp;</td><td>e.g. http://127.0.0.1:8983/PubmanConnector/collection1, no SLASH "/" at the end</td></tr>
+   
+    
+    </table>
+    <input type="submit" value="Change"><br/><br/>
+    </form>
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
+    
\ No newline at end of file
--- /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 @@
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
+    <h2>Add a new Ressource</h2>
+    <form name="form" action="changeMain">
+    <table> 
+      <tr><td> Title: </td><td><input type="text" name="title" tal:attributes="value here/title" size=50></td></tr>
+      <tr><td> url: </td><td><input type="text" name="pubmanURL" tal:attributes="value here/pubmanConnectorURL" size=50></td></tr>
+   	  <tr><td>&nbsp;</td><td>e.g. http://127.0.0.1:8983/PubmanConnector/collection1, no SLASH "/" at the end</td></tr>
+   
+     
+    </table>
+    <input type="submit" value="Change"><br/><br/>
+    </form>
+    
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
+    
\ No newline at end of file