Rev | Line | |
---|
[845] | 1 | ## Script (Python) "getCertificateInfo" |
---|
[556] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=student=None |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
[805] | 10 | # $Id: getCertificateInfo.py 1662 2007-03-30 08:11:21Z joachim $ |
---|
[556] | 11 | """ |
---|
| 12 | return Info about a Certificate |
---|
| 13 | """ |
---|
[1662] | 14 | def cmp_id(a,b): |
---|
| 15 | s1 = "%(id)s" % a |
---|
| 16 | s2 = "%(id)s" % b |
---|
| 17 | if s1 == s2: |
---|
| 18 | return 0 |
---|
| 19 | if s1 > s2: |
---|
| 20 | return 1 |
---|
| 21 | return -1 |
---|
| 22 | |
---|
[556] | 23 | request = context.REQUEST |
---|
| 24 | |
---|
| 25 | wf = context.portal_workflow |
---|
| 26 | path_info = request.get('PATH_INFO').split('/') |
---|
| 27 | |
---|
| 28 | info = {} |
---|
[1632] | 29 | info['action'] = "%s" % context.absolute_url() |
---|
[556] | 30 | info['choosen_ids'] = request.get('ids',[]) |
---|
| 31 | info['doc'] = context.getContent() |
---|
| 32 | items = [] |
---|
| 33 | levels = context.objectValues() |
---|
| 34 | for l in levels: |
---|
| 35 | row = {} |
---|
| 36 | ld = l.getContent() |
---|
| 37 | row['id'] = l.getId() |
---|
[577] | 38 | if hasattr(ld,'Title'): |
---|
| 39 | row['title'] = ld.Title() |
---|
| 40 | else: |
---|
| 41 | row['title'] = getattr(ld,'title','no title') |
---|
[556] | 42 | row['url'] = l.absolute_url() |
---|
| 43 | items.append(row) |
---|
[1662] | 44 | items.sort(cmp_id) |
---|
[556] | 45 | info['items'] = items |
---|
| 46 | return info |
---|
Note: See
TracBrowser for help on using the repository browser.