Changeset 142

Show
Ignore:
Timestamp:
02/27/06 15:07:43 (3 years ago)
Author:
tim
Message:

added breadcrumb exception handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tags/0.3.2/pyramid/page.py

    r42 r142  
    1313        pgen['divider'] = str 
    1414    return pgen 
     15class FragmentError(Exception): 
     16    """Base class for fragment exceptions.""" 
     17    pass 
    1518 
    1619class Fragment(rend.Page): 
     
    5861    def render_breadcrumb(self, ctx, data): 
    5962        tag = ctx.tag 
    60         for item in data[:-1]: 
    61             tag[ T.a(href=item['href'])[item['label']],' ',T.span(class_="breadcrumb-separator")[ T.xml('>') ] ,' '] 
    62         tag[ data[-1]['label'] ] 
     63        try: 
     64            for item in data[:-1]: 
     65                tag[ T.a(href=item['href'])[item['label']],' ',T.span(class_="breadcrumb-separator")[ T.xml('>') ] ,' '] 
     66            tag[ data[-1]['label'] ] 
     67        except IndexError: 
     68            raise FragmentError, 'An error has occured whilst building the breadcrumb trail. This usually occurs when a content template has a breadcrumb trail renderer but the parent nav.yml does not include a reference to the current templates directory. Use -V to find out more information about which page cause this error.' 
     69             
    6370        return tag 
    6471