[Zope-CMF] Avoiding login form

Thomas Olsen tol@tanghus.dk
Tue, 16 Apr 2002 02:05:39 +0200


Hi

I'm not sure whether this is CMF specific or general to Zope and I'm sure=
 its=20
an FAQ I just couldn't find but here goes:

I have a python script used to generate breadcrumbs. Whenever a user view=
 a=20
published item in an unpublished CMFArticle (PortalContent/PortalFolder=20
class) she gets redirected to the login form because the breadcrumbs scri=
pt=20
accesses the unpublished article higher up in the folder hierarchy.=20

When generating the breadcrumbs I just want to skip the items that the us=
er=20
isn't allowed to access but I cannot do it with a simple try/except=20
statement.

Here's the script::

from string import join

result =3D []
portal_url =3D context.portal_url()

if include_root:
    result.append( { 'id'      : 'Home'
                   , 'title'   :=20
context.truncID(context.portal_properties.title(),15)
                   , 'url'     : portal_url
                   }
                 )

relative =3D context.portal_url.getRelativeContentPath( context )
obj =3D portal =3D context.portal_url.getPortalObject()

for i in range( len( relative ) ):
    now =3D relative[ :i+1 ]
    obj =3D portal.restrictedTraverse( now )
    if obj:
       if not now[ -1 ] =3D=3D 'talkback':
            result.append( { 'id'      : now[ -1 ]
                    , 'title'   : context.truncID(obj.title_or_id(),15)
                    , 'url'     : portal_url + '/' + join( now, '/' )
                    }
                    )
return result

--=20
Regards,
=09Thomas Olsen