source: trunk/skins/toolbox/computeStoryRelatedItems.py @ 72

Revision 72, 1.0 KB checked in by meelis, 14 years ago (diff)

references #133 Story content type created has all described functionalities, but some of them has to be modified for better look

Line 
1## Script (Python) "computeStoryRelatedItems"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=what
8##title=find related items for an object
9##
10
11from AccessControl import Unauthorized
12
13if hasattr(context, 'getRelated'+what):
14    if what == 'Content':
15        outgoing = context.getRelatedContent()
16    if what == 'Activities':
17        outgoing = context.getRelatedActivities()
18    if what == 'Tools':
19        outgoing = context.getRelatedTools()
20    incoming = []
21    # if you want to show up the items which point to this one, too, then use the
22    # line below
23    #incoming = context.getBRefs('relatesTo')
24    res = []
25    mtool = context.portal_membership
26   
27    in_out = outgoing+incoming
28    for d in range(len(in_out)):
29        try:
30            obj = in_out[d]
31    except Unauthorized:
32            continue
33        if obj not in res:
34            if mtool.checkPermission('View', obj):
35                res.append(obj)
36   
37    return res
38
39
40
41
42
Note: See TracBrowser for help on using the repository browser.