[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL - Tree.py:1.1.2.1
Christian Theune
ct@gocept.com
Sat, 18 May 2002 06:42:24 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL
In directory cvs.zope.org:/tmp/cvs-serv2930
Added Files:
Tag: ctheune-foldermove-branch
Tree.py
Log Message:
Renamed Tree.py to ../../../Content/Folder/Views/XUL//Tree.py
=== Added File Zope3/lib/python/Zope/App/OFS/Content/Folder/Views/XUL/Tree.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
$Id: Tree.py,v 1.1.2.1 2002/05/18 10:42:23 ctheune Exp $
"""
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.App.OFS.IContainer import IReadContainer
class Tree(AttributePublisher):
""" """
__implements__ = AttributePublisher.__implements__
def __init__(self, context):
"""Initialize form.
"""
self._context = context
def _makeSubTree(self, base, prefix=''):
""" """
rdf = ''
local_links = ''
for item in base.objectItems():
# 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 IReadContainer.isImplementedBy(item[1]):
rdf += self._makeSubTree(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 getRDFTree(self, REQUEST=None):
''' '''
rdf = _rdf_start
rdf += self._makeSubTree(self.getContext(), '')
rdf += _rdf_end
REQUEST.response.setHeader('Content-Type', 'text/xml')
return rdf
def getContext(self):
""" """
return self._context
_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#">
'''
_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>
'''