Reputation: 45
The following browser view should return the content of the front page of the first Plone Site in it's context. However, I can not seem to obtain an object which is able to render html content.
from Products.Five import BrowserView
from zope.component import getMultiAdapter
class RenderFirst (BrowserView):
def __call__ (self):
def findPlones (context):
plones = context.objectValues("Plone Site")
folders = context.objectValues("Folder")
folders = set(folders).difference(set(plones))
for folder in folders:
plones += findPlones(folder)
return plones
plones = findPlones(context)
if len(plones):
default_page = plones[0].getDefaultPage()
content = plones[0].unrestrictedTraverse (default_page)
view = getMultiAdapter ((content, self.request))
return view()
else:
return "no plone"
The previous code when run tells me that the object view is not callable.
plones[0]
is a Plone Site object and when called produces a KeyError
for folder_listing
if I call the content
object I get an AttributeError
for document_view
There are lots of combinations here, of calling different adapters of different objects. Haven't yet found the right object which can render the page. Anyone know how to do this?
Upvotes: 2
Views: 430
Reputation: 2997
Take a look at http://pypi.python.org/pypi/plone.subrequest.
Upvotes: 1