[Zope-CVS] CVS: Packages/Moztop/idesupport/rdf - container.py:1.3
Stephan Richter
srichter@cbu.edu
Thu, 16 Jan 2003 04:56:07 -0500
Update of /cvs-repository/Packages/Moztop/idesupport/rdf
In directory cvs.zope.org:/tmp/cvs-serv24088/idesupport/rdf
Modified Files:
container.py
Log Message:
- We now have the sense of a first static TypeRegistry. Much more work is
needed in this area.
- If you have an image, you can now save its meta data and see the Upload
screen. Trying to open the File Picker somehow crashes my Mozilla.
- All types that Zope supports are now listed and can be handled in the
contents.rdf file.
=== Packages/Moztop/idesupport/rdf/container.py 1.2 => 1.3 ===
--- Packages/Moztop/idesupport/rdf/container.py:1.2 Mon Jan 13 21:43:42 2003
+++ Packages/Moztop/idesupport/rdf/container.py Thu Jan 16 04:55:35 2003
@@ -15,29 +15,63 @@
$Id$
"""
+from zope.app.browser.container.adding import Adding
+from zope.component import getFactoryInterfaces, getService
from zope.app.interfaces.container import IContainer, IZopeContainer
from zope.publisher.browser import BrowserView
-
+from zope.app.content.folder import RootFolder
class Contents(BrowserView):
__used_for__ = IContainer
+ _map = None
+
+ def _createNameInterfacesMapping(self):
+ if self._map is not None:
+ return self._map
+ self._map = {}
+ info = Adding(self.context, self.request).addingInfo()
+ service = getService(None, 'Factories')
+ for type in info:
+ self._map[type['action']] = service.getInterfaces(type['action'])
+ return self._map
+
+ def _getContentTypeOfObject(self, obj):
+ # Handle RootFolder special, since it is not in Factory Service
+ if obj.__class__ == RootFolder:
+ return 'Folder'
+ service = getService(None, 'Factories')
+ for name in service._GlobalFactoryService__factories.keys():
+ try:
+ if obj.__class__ == service.createObject(name).__class__:
+ return name
+ except:
+ pass
+
+ def _createContentList(self):
+ adding = Adding(self.context, self.request)
+ info = adding.addingInfo()
+ res = ""
+ for type in info:
+ res += (' <rdf:Description ' +
+ 'ID="%(action)s" dc:title="%(title)s"/>\n' %type)
+ return res
def _make_subtree(self, id, base, prefix=''):
rdf = ''
fillIn = {'title': id[1:],
'rdf_url': prefix + id,
- 'sub_nodes': ''}
-
- if IContainer.isImplementedBy(base):
+ 'sub_nodes': '',
+ 'type': self._getContentTypeOfObject(base)}
+
+ if fillIn['type'] in ['Folder', 'RootFolder']:
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
@@ -46,7 +80,6 @@
rdf += self._make_subtree(':'+item[0], item[1],
fillIn['rdf_url'])
else:
- fillIn['type'] = 'document'
rdf += _node %fillIn
return rdf
@@ -55,7 +88,7 @@
def contents(self):
rdf = _rdf_start
rdf += self._make_subtree('', self.context)
- rdf += _rdf_end
+ rdf += _rdf_end %self._createContentList()
self.request.response.setHeader('Content-Type', 'text/xml')
return rdf
@@ -68,9 +101,7 @@
'''
_rdf_end = '''
-<rdf:Description ID="folder" dc:title="Folder"/>
-<rdf:Description ID="document" dc:title="Document"/>
-
+%s
</rdf:RDF>
'''