[CMF-checkins] SVN: CMF_Extras/trunk/CMFCollector/ Added script / template to render a search query as RDF.

Tres Seaver tseaver at palladion.com
Wed Feb 6 01:56:41 EST 2008


Log message for revision 83570:
  Added script / template to render a search query as RDF.
  

Changed:
  U   CMF_Extras/trunk/CMFCollector/CHANGES.txt
  A   CMF_Extras/trunk/CMFCollector/skins/collector/issues_as_rdf.pt
  A   CMF_Extras/trunk/CMFCollector/skins/collector/query_rdf.py

-=-
Modified: CMF_Extras/trunk/CMFCollector/CHANGES.txt
===================================================================
--- CMF_Extras/trunk/CMFCollector/CHANGES.txt	2008-02-06 01:01:59 UTC (rev 83569)
+++ CMF_Extras/trunk/CMFCollector/CHANGES.txt	2008-02-06 06:56:40 UTC (rev 83570)
@@ -4,6 +4,8 @@
 
     Features
 
+      - Added script / template to render a search query as RDF.
+
       - Added marker interfaces to collector and issue objects.
 
       - Added RSS syndication link, which creates a feed using the

Added: CMF_Extras/trunk/CMFCollector/skins/collector/issues_as_rdf.pt
===================================================================
--- CMF_Extras/trunk/CMFCollector/skins/collector/issues_as_rdf.pt	                        (rev 0)
+++ CMF_Extras/trunk/CMFCollector/skins/collector/issues_as_rdf.pt	2008-02-06 06:56:40 UTC (rev 83570)
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<rdf:RDF
+    xmlns:tal="http://xml.zope.org/namespaces/tal"
+    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns:dc="http://purl.org/dc/elements/1.1/#"
+    xmlns:collector="http://namespaces.zope.org/cmfcollector#">
+ <rdf:Seq about="#"
+          tal:attributes="about string:${context/absolute_url}/supporters">
+  <rdf:li tal:repeat="item options/supporters">
+   <rdf:Description
+      about="#"
+      tal:attributes="about string:${context/absolute_url}/supporters/${item}">
+    <collector:supporter tal:content="item">SUPPORTER</collector:supporter>
+   </rdf:Description>
+  </rdf:li>
+ </rdf:Seq>
+ <rdf:Seq about="#"
+          tal:attributes="about string:${context/absolute_url}/status">
+  <rdf:li tal:repeat="item options/status">
+   <rdf:Description
+      about="#"
+      tal:attributes="about string:${context/absolute_url}/status/${item}">
+    <collector:status tal:content="item">STATUS</collector:status>
+   </rdf:Description>
+  </rdf:li>
+ </rdf:Seq>
+ <rdf:Seq about="#"
+          tal:attributes="about string:${context/absolute_url}/topic">
+  <rdf:li tal:repeat="item options/topic">
+   <rdf:Description
+      about="#"
+      tal:attributes="about string:${context/absolute_url}/topic/${item}">
+    <collector:topic tal:content="item">TOPIC</collector:topic>
+   </rdf:Description>
+  </rdf:li>
+ </rdf:Seq>
+ <rdf:Seq about="#"
+          tal:attributes="about string:${context/absolute_url}/classification">
+  <rdf:li tal:repeat="item options/classification">
+   <rdf:Description
+      about="#"
+      tal:attributes="about string:${context/absolute_url}/classification/${item}">
+    <collector:classification tal:content="item">CLASSIFICATION</collector:classification>
+   </rdf:Description>
+  </rdf:li>
+ </rdf:Seq>
+ <rdf:Seq about="#"
+          tal:attributes="about string:${context/absolute_url}/importance">
+  <rdf:li tal:repeat="item options/importance">
+   <rdf:Description
+      about="#"
+      tal:attributes="about string:${context/absolute_url}/importance/${item}">
+    <collector:importance tal:content="item">IMPORTANCE</collector:importance>
+   </rdf:Description>
+  </rdf:li>
+ </rdf:Seq>
+ <rdf:Seq about="#"
+          tal:attributes="about string:${context/absolute_url}/items">
+  <rdf:li tal:repeat="item options/issues">
+   <rdf:Description about="#"
+                    tal:attributes="about item/url">
+    <dc:identifier tal:content="item/url">IDENTIFIER</dc:identifier>
+    <dc:title tal:content="item/title">TITLE</dc:title>
+    <dc:date tal:content="item/date">YYYY-MM-DDTHH:MM:SSZ</dc:date>
+    <dc:description
+        tal:condition="item/description"
+        tal:content="item/description">DESCRIPTION</dc:description>
+    <dc:creator
+        tal:repeat="creator item/creators"
+        tal:content="creator">CREATOR</dc:creator>
+    <collector:number
+        tal:content="item/number">NUMBER</collector:number>
+    <collector:supporter
+        tal:repeat="contributor item/contributors"
+        tal:content="contributor">SUPPORTER</collector:supporter>
+    <collector:responses
+        tal:content="item/responses">NUMBER</collector:responses>
+    <collector:status
+        tal:content="item/status">STATUS</collector:status>
+    <collector:topic
+        tal:content="item/topic">TOPIC</collector:topic>
+    <collector:classification
+        tal:content="item/classification">CLASSIFICATION</collector:classification>
+    <collector:importance
+        tal:content="item/importance">IMPORTANCE</collector:importance>
+   </rdf:Description>
+  </rdf:li>
+ </rdf:Seq>
+</rdf:RDF>

Added: CMF_Extras/trunk/CMFCollector/skins/collector/query_rdf.py
===================================================================
--- CMF_Extras/trunk/CMFCollector/skins/collector/query_rdf.py	                        (rev 0)
+++ CMF_Extras/trunk/CMFCollector/skins/collector/query_rdf.py	2008-02-06 06:56:40 UTC (rev 83570)
@@ -0,0 +1,52 @@
+##Script (Python) "query_rdf"
+##Title: Return a given query as RDF
+##parameters=REQUEST
+
+REQUEST.RESPONSE.setHeader('Content-Type', 'application/xml')
+
+kw = REQUEST.form
+
+options = {}
+
+query = kw.copy()
+query['portal_type'] = 'Collector Issue'
+
+if 'sort_on' not in query:
+    query['sort_on'] = 'getId'
+
+if 'supporters' in query:
+    query['assigned_to'] = query['supporters']
+    del query['supporters']
+
+catalog = context.get_internal_catalog()
+found = catalog.search(query_request=query, sort_index='modified', reverse=True)
+
+items = []
+for item in found:
+    info = {'url': item.getURL(),
+            # dc namespace
+            'title': item.Title,
+            'description': item.Description,
+            'subjects': (),
+            'creators': (item.submitter_id,),
+            'contributors': item.assigned_to,
+            'date': item.modified.HTML4(),
+            # cmfcollector namespace
+            'number': int(item.getId),
+            'responses': item.action_number,
+            'status': item.status,
+            'importance': item.importance,
+            'topic': item.topic,
+            'classification': item.classification,
+           }
+    items.append(info)
+
+options['issues'] = tuple(items)
+
+options['supporters'] = catalog.supporters
+options['status'] = catalog.uniqueValuesFor('status')
+options['topic'] = catalog.topics
+options['classification'] = catalog.classifications
+options['importance'] = catalog.importances
+
+return context.issues_as_rdf(**options)



More information about the CMF-checkins mailing list