I have spend reasonable time to get parent object for navigation for zope/plone site.I have come up with my script which might be helpful for someone.
root = ('',)
vRoot = context.REQUEST.VirtualRootPhysicalPath
PARENTS = context.REQUEST.PARENTS
PARENTS.reverse()
if vRoot:
root = vRoot #inside if block
PARENTS = PARENTS[len(vRoot)-1:] #inside if block
try:
if PARENTS[-1].meta_type != 'ATFolder':
return PARENTS[-3]
else:
return PARENTS[-2]
except IndexError :
return PARENTS[0]

Leave a Reply