## Script (Python) "getCertificateInfo"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=student=None
##title=
##
# $Id: getCertificateInfo.py 1662 2007-03-30 08:11:21Z joachim $
"""
return Info about a Certificate
"""
def cmp_id(a,b):
    s1 = "%(id)s" % a
    s2 = "%(id)s" % b
    if s1 == s2:
        return 0
    if s1 > s2:
        return 1
    return -1

request = context.REQUEST

wf = context.portal_workflow
path_info = request.get('PATH_INFO').split('/')

info = {}
info['action'] = "%s" % context.absolute_url()
info['choosen_ids'] = request.get('ids',[])
info['doc'] = context.getContent()
items = []
levels = context.objectValues()
for l in levels:
    row = {}
    ld = l.getContent()
    row['id'] = l.getId()
    if hasattr(ld,'Title'):
        row['title'] = ld.Title()
    else:
        row['title'] = getattr(ld,'title','no title')
    row['url'] = l.absolute_url()
    items.append(row)
items.sort(cmp_id)
info['items'] = items
return info
