Changeset 140

Show
Ignore:
Timestamp:
02/27/06 09:59:49 (3 years ago)
Author:
tim
Message:

updated from 0.3.2 tweaks and added exception handling on breadcrumb failure

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/timhtcopy/pyramid/build.py

    r136 r140  
    176176    parser.add_option("-R", "--rebuilddirs",dest="rebuilddirs",help="only rebuild below these comma separated directories",metavar="REBUILDDIRS") 
    177177    parser.add_option("-c", "--constants", dest="constants", help="pass in the names constants (e.g. PDO=/root/pdo,PSF=/psf", metavar="CONSTANTS") 
    178     parser.add_option("-U", "--update", action="store_true", dest="update", default=False, help="NOT WORKING try to build only those pages that have changed")     
     178    parser.add_option("-U", "--update", action="store_true", dest="update", default=False, help="NOT WORKING DO NOT USE try to build only those pages that have changed")     
    179179    (options, args) = parser.parse_args() 
    180180    main(options,args) 
  • branches/timhtcopy/pyramid/flatteners.py

    r136 r140  
    129129class WikiUrlFlattener(components.Adapter): 
    130130    def flatten(self, ctx, dir): 
    131         from pyramid import moinmoin 
    132         url = expandConstants(ctx,dir,self.original) 
    133         from pprint import pprint 
    134         pprint(url) 
    135         contents = moinmoin.parse(url) 
     131        try: 
     132            from pyramid import moinmoin 
     133            url = expandConstants(ctx,dir,self.original) 
     134            contents = moinmoin.parse(url) 
     135        except: 
     136            print 'moinmoin parse error, replacing with a marker' 
     137            contents = '<strong>MoinMoin parse failed for %s - a wiki instance needs to be installed and the wikiconfig.py directory needs to be on the $PYTHONPATH</strong>'%url 
    136138        return T.xml(contents) 
    137139         
  • branches/timhtcopy/pyramid/mkpydir.py

    r127 r140  
    4646def mkpydir(directive,prefix,path,outputdir,copy,title): 
    4747    OUTPUTDIR = os.path.abspath(outputdir) 
    48     os.mkdir(OUTPUTDIR) 
     48    if os.path.isdir(outputdir) is not True: 
     49        os.mkdir(OUTPUTDIR) 
    4950     
    5051    if directive == 'htfile': 
     
    9192 
    9293def parseOptions(): 
    93     usage = "usage: mkpydir -t <type (wikiurl|htfile|html|rest)> [-d <prefixdirforsourcefile>] -p <pathtosourcefile> -o <outputdir> [-l] [-R]" 
     94    usage = """usage: mkpydir -t <type (wikiurl|htfile|html|restfile)> [-d <prefixdirforsourcefile>] -p <pathtosourcefile> -o <outputdir> [-l] [-R] 
     95examples 
     96  to create a page from a restructured text file 
     97     mkpydir -t restfile -d $HOME/pythondocs -p mypage.rst -o $HOME/beta.python.org/build/data/mynewpagedir 
     98  to create a page from a htfile file (copying the contents into the pyramid dir) 
     99     mkpydir -t htfile -d $HOME/pydotorg/trunk -p /Help.ht -o $HOME/beta.python.org/build/data/help 
     100  to link in some content from the pydotorg tree such that it always builds from the original 
     101     mkpydir -t htfile -l -p /Help.ht -o $HOME/beta.python.org/build/data/help 
     102  to include a wiki page 
     103     mkpydir -t wikiurl -d http://wiki.python.org/moin -p /Applications -o $HOME/beta.python.org/build/data/applications 
     104  to perform the above operation and create the page below the current directory 
     105     mkpydir -t wikiurl -d http://wiki.python.org/moin -p /Applications -o . 
     106    """ 
    94107    parser = OptionParser(usage) 
    95108    parser.add_option("-t", "--type", dest="type", help="the type of pydir content to be created", metavar="TYPE") 
    96     parser.add_option("-d", "--dir", dest="dir", help="the root directory for the an asset (to be used when sourcing pydotorg or wiki content)", metavar="DIR") 
     109    parser.add_option("-d", "--dir", dest="dir", help="the root directory for the an asset (to be used when copying pydotorg or wiki content)", metavar="DIR") 
    97110    parser.add_option("-p", "--path", dest="path", help="the path to the asset", metavar="PATH") 
    98111    parser.add_option("-o", "--outputdir", dest="outputdir", help="directory in which to create the pyramid directory", metavar="OUTPUTDIR") 
  • branches/timhtcopy/pyramid/page.py

    r42 r140  
     1import sys 
    12from nevow import rend, stan, flat, compy as components, tags as T 
    23from nevow.loaders import xmlstr 
     
    1314        pgen['divider'] = str 
    1415    return pgen 
     16 
     17class FragmentError(Exception): 
     18    """Base class for fragment exceptions.""" 
     19    pass 
    1520 
    1621class Fragment(rend.Page): 
     
    5863    def render_breadcrumb(self, ctx, data): 
    5964        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('&gt;') ] ,' '] 
    62         tag[ data[-1]['label'] ] 
     65        print data 
     66        try: 
     67            for item in data[:-1]: 
     68                tag[ T.a(href=item['href'])[item['label']],' ',T.span(class_="breadcrumb-separator")[ T.xml('&gt;') ] ,' '] 
     69            tag[ data[-1]['label'] ] 
     70        except IndexError: 
     71            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.' 
     72             
    6373        return tag 
    6474