[Zope-CVS] CVS: Packages/Moztop/idesupport/rdf - container.py:1.2
Stephan Richter
srichter@cbu.edu
Mon, 13 Jan 2003 21:44:14 -0500
Update of /cvs-repository/Packages/Moztop/idesupport/rdf
In directory cvs.zope.org:/tmp/cvs-serv17260/idesupport/rdf
Modified Files:
container.py
Log Message:
Made Zope 3-based content RDF apply to Paul's structure changes and
made refresh work again. Unfortunately it is a big hack right now.
Also, Adding and deleting Sites should work, but it does not, but no
errors are thrown... I am lost there.
=== Packages/Moztop/idesupport/rdf/container.py 1.1 => 1.2 ===
--- Packages/Moztop/idesupport/rdf/container.py:1.1 Mon Jan 13 15:03:51 2003
+++ Packages/Moztop/idesupport/rdf/container.py Mon Jan 13 21:43:42 2003
@@ -24,36 +24,37 @@
__used_for__ = IContainer
- def _make_subtree(self, base, prefix=''):
+ def _make_subtree(self, id, base, prefix=''):
rdf = ''
- local_links = ''
- for item in base.items():
-
- # first we need to create the meta data for this item
- fillIn = {'id': item[0],
- 'rdf_url': prefix + ':' + item[0]}
- rdf += _node_description %fillIn + '\n\n'
-
- # now we add the link to the base
- local_links += '''<RDF:li resource="urn:explorer%(rdf_url)s"/>\n''' %fillIn
-
- if IContainer.isImplementedBy(item[1]):
- rdf += self._make_subtree(item[1], fillIn['rdf_url'])
-
- fillIn = {'links': local_links,
- 'rdf_url': prefix}
- if prefix and local_links:
- rdf += _folder_node_links %fillIn
- elif not prefix and local_links:
- rdf += _root_folder_node_links %local_links
+ fillIn = {'title': id[1:],
+ 'rdf_url': prefix + id,
+ 'sub_nodes': ''}
+
+ if IContainer.isImplementedBy(base):
+ items = base.items()
+ subs = []
+ for item in items:
+ subs.append(
+ ' <rdf:li resource="urn:explorer:data%s:%s"/>' %(
+ fillIn['rdf_url'], item[0]))
+ fillIn['type'] = 'folder'
+ if subs:
+ fillIn['sub_nodes'] = "\n" + _sub_nodes %'\n'.join(subs)
+ rdf += _node %fillIn
+
+ for item in items:
+ rdf += self._make_subtree(':'+item[0], item[1],
+ fillIn['rdf_url'])
+ else:
+ fillIn['type'] = 'document'
+ rdf += _node %fillIn
return rdf
def contents(self):
- ''' '''
rdf = _rdf_start
- rdf += self._make_subtree(self.context, '')
+ rdf += self._make_subtree('', self.context)
rdf += _rdf_end
self.request.response.setHeader('Content-Type', 'text/xml')
return rdf
@@ -61,29 +62,28 @@
_rdf_start = '''<?xml version="1.0"?>
-<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:EXPLORER="http://www.zope.org/rdf/content#">
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:nc="http://home.netscape.com/NC-rdf#"
+ xmlns:dc="http://www.purl.org/dc/1.1#">
'''
_rdf_end = '''
-</RDF:RDF>
-'''
+<rdf:Description ID="folder" dc:title="Folder"/>
+<rdf:Description ID="document" dc:title="Document"/>
-_node_description = '''
- <RDF:Description about="urn:explorer%(rdf_url)s">
- <EXPLORER:name>%(id)s</EXPLORER:name>
- </RDF:Description>
+</rdf:RDF>
'''
-
-_folder_node_links = '''
- <RDF:Seq about="urn:explorer%(rdf_url)s">
- %(links)s
- </RDF:Seq>
+_node = '''
+<rdf:Description rdf:about="urn:explorer:data%(rdf_url)s">%(sub_nodes)s
+ <dc:title>%(title)s</dc:title>
+ <nc:resourcetype resource="#%(type)s"/>
+</rdf:Description>
'''
-_root_folder_node_links = '''
- <RDF:Seq about="urn:explorer:data">
- %s
- </RDF:Seq>
-'''
+_sub_nodes = '''\
+ <nc:subitems>
+ <rdf:Seq>
+%s
+ </rdf:Seq>
+ </nc:subitems>'''