[Zope-CVS] CVS: Packages/Moztop/idesupport/rdf - __init__.py:1.1 configure.zcml:1.1 container.py:1.1
Stephan Richter
srichter@cbu.edu
Mon, 13 Jan 2003 15:03:54 -0500
Update of /cvs-repository/Packages/Moztop/idesupport/rdf
In directory cvs.zope.org:/tmp/cvs-serv25212/idesupport/rdf
Added Files:
__init__.py configure.zcml container.py
Log Message:
- Site Contents is now obtained from Zope 3 via RDF.
- Updated CHANGES.txt and moved some tasks around.
=== Added File Packages/Moztop/idesupport/rdf/__init__.py ===
##############################################################################
#
# Copyright (c) 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Moztop Extension Product
$Id: __init__.py,v 1.1 2003/01/13 20:03:51 srichter Exp $
"""
=== Added File Packages/Moztop/idesupport/rdf/configure.zcml ===
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser" >
<browser:pages
for="zope.app.interfaces.container.IContainer"
permission="zope.ManageContent"
class=".container.Contents" >
<browser:page name="contents.rdf" attribute="contents" />
</browser:pages>
</zopeConfigure>
=== Added File Packages/Moztop/idesupport/rdf/container.py ===
##############################################################################
#
# Copyright (c) 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Container RDF views.
$Id: container.py,v 1.1 2003/01/13 20:03:51 srichter Exp $
"""
from zope.app.interfaces.container import IContainer, IZopeContainer
from zope.publisher.browser import BrowserView
class Contents(BrowserView):
__used_for__ = IContainer
def _make_subtree(self, 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
return rdf
def contents(self):
''' '''
rdf = _rdf_start
rdf += self._make_subtree(self.context, '')
rdf += _rdf_end
self.request.response.setHeader('Content-Type', 'text/xml')
return rdf
_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_end = '''
</RDF:RDF>
'''
_node_description = '''
<RDF:Description about="urn:explorer%(rdf_url)s">
<EXPLORER:name>%(id)s</EXPLORER:name>
</RDF:Description>
'''
_folder_node_links = '''
<RDF:Seq about="urn:explorer%(rdf_url)s">
%(links)s
</RDF:Seq>
'''
_root_folder_node_links = '''
<RDF:Seq about="urn:explorer:data">
%s
</RDF:Seq>
'''