try / except pour démarrer sans Solr.
[Plinn.git] / skins / custom_generic / breadcrumbs.py
1 ##parameters=include_root=1
2 ##title=Return breadcrumbs
3 ##
4 from string import join
5
6 result = []
7 portal_url = context.portal_url()
8
9 if include_root:
10 result.append( { 'id' : 'root'
11 , 'title' : context.portal_properties.title()
12 , 'url' : portal_url
13 }
14 )
15
16 relative = context.portal_url.getRelativeContentPath( context )
17 portal = context.portal_url.getPortalObject()
18 checkPermission = context.portal_membership.checkPermission
19 from Products.CMFCore.permissions import View
20
21 for i in range( len( relative ) ):
22 now = relative[ :i+1 ]
23 obj = portal.restrictedTraverse( now )
24 if not now[ -1 ] == 'talkback':
25 result.append( { 'id' : now[ -1 ]
26 , 'title' : obj.title_or_id()
27 , 'url' : checkPermission(View, obj) and (portal_url + '/' + join( now, '/' )) or None
28 }
29 )
30
31 return result