Back to index

plone3  3.1.7
getObjPositionInParent.py
Go to the documentation of this file.
00001 ## Script (Python) "getObjPositionInParent"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=
00008 ##title=
00009 ##
00010 from Products.CMFCore.utils import getToolByName
00011 Discussable = 'Products.CMFCore.interfaces.Discussions.Discussable'
00012 
00013 interface = getToolByName(container, 'portal_interface')
00014 parent = context.aq_inner.aq_parent
00015 
00016 # Stupid, stupid DiscussionItemContainer...
00017 if interface.objectImplements(parent, Discussable):
00018     return 0
00019 
00020 getpos = getattr(parent.aq_inner.aq_explicit, 'getObjectPosition', None)
00021 if getpos is not None:
00022     return getpos(context.getId())
00023 else:
00024     return 0