changeset 276:c886c0cb3455

added xml export for projects.
author casties
date Mon, 23 Feb 2015 22:47:36 +0100
parents 3f9ba7a8cb27
children d8a4ae8db589
files MPIWGProjects.py zpt/project/all_projects_xml.zpt zpt/project/project_index_xml.zpt
diffstat 3 files changed, 75 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MPIWGProjects.py	Wed Oct 08 15:18:19 2014 +0200
+++ b/MPIWGProjects.py	Mon Feb 23 22:47:36 2015 +0100
@@ -380,6 +380,7 @@
     # templates
     #
     project_html = PageTemplateFile('zpt/project/project_index_html', globals())
+    project_xml = PageTemplateFile('zpt/project/project_index_xml', globals())
     # edit templates
     edit_css = ImageFile('css/edit.css', globals())
     # make css refreshable for development
@@ -443,6 +444,13 @@
         # render template
         return pt()
 
+    def index_xml(self):
+        """default xml representation"""
+        # get template
+        pt = self.project_xml
+        # render template
+        return pt()
+
 
     redirect =  MPIWGHelper.redirect
 
@@ -1928,6 +1936,8 @@
     meta_type = "MPIWGProjectFolder"
     security = ClassSecurityInfo()
     
+    allprojects_xml = PageTemplateFile('zpt/project/all_projects_xml', globals())
+    
     # cached HashTree with project hierarchy
     _v_projectTree = None
                     
@@ -1949,6 +1959,14 @@
         return tree
     
     
+    def index_xml(self):
+        """default xml representation"""
+        # get template
+        pt = self.allprojects_xml
+        # render template
+        return pt()
+
+    
     def getProjectsAsList(self, start=None, active=1, archived=1, depthFirst=True, filter=None):
         """Return flattened list of projects, starting from start.
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/project/all_projects_xml.zpt	Mon Feb 23 22:47:36 2015 +0100
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<projects xmlns:tal="http://xml.zope.org/namespaces/tal"
+  xmlns:metal="http://xml.zope.org/namespaces/metal">
+  <project tal:define="start python:int(request.get('start', 0)); end python:int(request.get('end', 10000));" 
+    tal:repeat="project python:here.getProjectsAsList(start=None, active=0, archived=0)[start:end]"
+    tal:replace="structure python:project.index_xml()[22:]"/>
+</projects>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/project/project_index_xml.zpt	Mon Feb 23 22:47:36 2015 +0100
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<project xmlns:tal="http://xml.zope.org/namespaces/tal"
+  xmlns:metal="http://xml.zope.org/namespaces/metal">
+  <id tal:content="here/getId"/>
+  <title tal:content="here/getProjectTitle">History of Scientific Objectivity, 18th-19th Cs</title>
+  <label tal:content="here/getLabel"/>
+  <projectstarted tal:content="here/getStartedAt"/>
+  <projectcompleted tal:content="here/getCompletedAt"/>
+  <type tal:content="here/getProjectType"/>
+  <number tal:content="here/getNumber"/>
+  <active tal:content="here/isActiveProject"/>
+  <responsiblescientists tal:attributes="textlist here/getResponsibleScientists">
+    <scientist tal:repeat="person here/getResponsibleScientistsList" 
+      tal:attributes="username person/username|nothing; key person/key|nothing"/>
+  </responsiblescientists>
+  <involvedscholars tal:content="here/getInvolvedScholars"/>
+  <cooperationpartners tal:content="here/getCooperationPartners"/>
+  <images>
+    <image tal:repeat="image here/getImageList">
+      <src tal:content="image/getUrl"/>
+      <link tal:content="image/getLink"/>
+      <caption tal:content="image/caption"/>
+    </image>
+  </images>
+  <description tal:content="python:here.getDescription(filter=True)">Project description</description>
+  <relatedprojects>
+    <project tal:repeat="project here/getRelatedProjectList" 
+      tal:attributes="id project/getProjectId" tal:content="project/getProjectLabel"/>
+  </relatedprojects>
+  <relatedpublications>
+    <publication tal:repeat="publication here/getPublicationList"
+      tal:attributes="bookid publication/getBookId|nothing; image publication/publicationImage1/absolute_url|nothing; link publication/link; description publication/description|nothing;"
+      tal:content="publication/text|nothing"/>
+  </relatedpublications>
+  <pubmanpublications>
+  <!-- TODO: see show_publications -->
+  </pubmanpublications>
+  <infoblocks>
+    <infoblock tal:repeat="block here/getInfoBlockList">
+      <title tal:content="block/getTitle"></title>
+      <item tal:repeat="item block/getItems"
+        tal:attributes="link item/link" tal:content="item/text"/>
+    </infoblock>
+  </infoblocks>
+  <tal:block tal:define="cal here/getProjectCalendar">
+  <projectcalendar tal:condition="cal" 
+    tal:attributes="url cal/url; only_upcoming python:cal.getFlag('only_upcoming'); num python:cal.getFlag('show_num', 5)"/>
+  </tal:block>
+  <fundinginstitutions tal:content="here/getFundingInstitutions"/>
+</project>
\ No newline at end of file