~mnordhoff/loggerhead/cheezum

« back to all changes in this revision

Viewing changes to loggerhead/util.py

Support serving /robots.txt when using apps.transport (serve-branches or bzr serve --http)

Show diffs side-by-side

added added

removed removed

Lines of Context:
587
587
            if exit_code != 3:
588
588
                return exit_code
589
589
            print '-'*20, 'Restarting', '-'*20
 
590
 
 
591
 
 
592
def convert_file_errors(application):
 
593
    """WSGI wrapper to convert some file errors to Paste exceptions"""
 
594
    def new_application(environ, start_response):
 
595
        try:
 
596
            return application(environ, start_response)
 
597
        except (IOError, OSError), e:
 
598
            import errno
 
599
            from paste import httpexceptions
 
600
            if e.errno == errno.ENOENT:
 
601
                raise httpexceptions.HTTPNotFound()
 
602
            elif e.errno == errno.EACCES:
 
603
                raise httpexceptions.HTTPForbidden()
 
604
            else:
 
605
                raise
 
606
    return new_application