I cannot slice context.REQUEST.PARENTS

The reason I want to do this is to travel up the URL tree for a
breadcrumb navigation do-hicky.

I want to slice it so I can make a copy because if I just do
...reverse() on it, I screw up everything afterwards.

It says I'm unauthorized (Guarded.py __careful_getattr__) so I
assume this is a feature.

I suppose I can just .reverse() it back again at the end, but it
seems.....wrong some how.

Attached is my code at the moment...it sucks, I know.  This is
python project numero uno and zope project duo...

If anyone has a better example of how to hand text (I'm using buff
and returning it) back, I'd appreciate it.

I'm much to tired, so off I go to bed...


Man is the best computer we can put aboard a spacecraft ... and the only one that can 
be mass produced with unskilled labor.
         -- Wernher von Braun

The Doctor What: <fill in the blank>             http://docwhat.gerf.org/
[EMAIL PROTECTED]                                                   KF6VNC
This is a breadcrumb generator.  A breadcrumb trail is what you get at yahoo as
you traverse downward in their directory structure:

It shows you where you are in your site.

My breadcrumbs shall follow these rules:
1) The current DTML Document shall be the last item.  It will not be a link.
2) If the current DTML Document isn't index_html, then the parent crumb will be
   the index_html for the folder
3) All crumb names are overridable by setting the 'nickname' attribute.
4) The root folder will always be called "Home"



## Start being crumb-y!
buff = "\n<!-- start Breadcrumbs -->\n[ "

# Get the list of parents and reverse it
list = context.REQUEST.PARENTS[:]

# Iterate over all the parent objects, skipping the 'current'one
# (see below for dealing with that
for x in range(lose,len(list)-1):
    obj = list[x]

    url = obj.absolute_url()
    name = obj.title_or_id()
    buff = "%s\n -> <a href='%s'>%s</a>" % (buff, url, name)

# Deal with the 'current' object(s)
obj = list[-1]

buff = "%s\n    '%s'" % (buff, obj)
buff = "%s\n    '%s'" % (buff, context.id)

if obj != context:
    buff = "%s\n  -> '%s'" % (buff, obj.title_or_id())

buff = "%s\n  -> '%s'" % (buff, obj.title_or_id())

buff = buff + "\n]\n<!-- end Breadcrumbs -->\n"

return buff

Reply via email to