## Script (Python) "getDocumentsInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None ##title= ## # $Id:getFacultiesInfo.py 486 2006-09-06 10:09:39Z joachim $ """ return Info about the Faculties """ request = context.REQUEST 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 wf = context.portal_workflow mtool = context.portal_membership 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 = [] # facs = context.portal_catalog(portal_type='WAeUPDocument') # for f in facs: # row = {} # fo = f.getObject() # fd = fo.getContent() # row['id'] = fo.getId() # row['title'] = fd.Title() # row['url'] = fo.absolute_url() # row['is_editable'] = mtool.checkPermission('Modify portal content', fo) # items.append(row) # items.sort(cmp_id) items = [] for id, doc in context.objectItems(): row = {} row['id'] = id row['title'] = doc.getContent().Title() row['url'] = doc.absolute_url() row['is_editable'] = mtool.checkPermission('Modify portal content', doc) items.append(row) items.sort(cmp=lambda x,y: cmp(x['id'].lower(), y['id'].lower())) info['items'] = items return info