Parent objects of the folder in Zope/Plone Framework

Parent objects of the folder in Zope/Plone Framework

To get parent object for navigation for zope navigation framework. Following script which might be helpful.

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]
Share

Leave a Reply

Your email address will not be published. Required fields are marked *