示例#1
0
    def formatted_page_not_found():
        """Page not found formatter."""
        urls = Storage({})
        urls.invalid = '{scheme}://{host}{uri}'.format(
            scheme=request.env.wsgi_url_scheme or 'https',
            host=request.env.http_host,
            uri=request.env.web2py_original_uri or request.env.request_uri
        )

        urls.suggestions = [
            {
                'label': 'All torrent:',
                'url': URL(host=True, **(Zco().all_torrent_url)),
            },
        ]

        creator_row = db(db.creator.torrent != None).select(
            orderby='<random>', limitby=(0, 1)).first()
        try:
            creator = Creator.from_id(creator_row.id)
        except LookupError:
            pass
        else:
            urls.suggestions.append({
                'label': 'Cartoonist torrent:',
                'url': creator_torrent_url(creator, host=True),
            })

        book_row = db(db.book.torrent != None).select(
            orderby='<random>', limitby=(0, 1)).first()
        try:
            book = Book.from_id(book_row.id)
        except LookupError:
            pass
        else:
            urls.suggestions.append({
                'label': 'Book torrent:',
                'url': book_torrent_url(book, host=True),
            })

        response.view = 'errors/page_not_found.html'
        message = 'The requested torrent was not found on this server.'
        return dict(urls=urls, message=message)
示例#2
0
def page_not_found():
    """Page not found. Used if an invalid url is provided.

    request.vars.invalid_url: string, optional, url user used.
    """
    deprecated_default_functions = [
        'about',
        'contribute',
        'copyright_claim',
        'expenses',
        'faq',
        'faqc',
        'files',
        'logos',
        'modal_error',
        'monies',
        'overview',
        'terms',
        'todo',
    ]

    urls = Storage({})
    urls.suggestions = []
    if request.vars.request_url \
            and request.vars.request_url.startswith('/zcomx/default'):
        parts = request.vars.request_url.split('/')
        if len(parts) >= 3:
            func_name = parts[3]
            if func_name in deprecated_default_functions:
                urls.suggestions.append({
                    'label': func_name + ':',
                    'url': URL(c='z', f=func_name, host=True)
                })
    urls.invalid = request.vars.request_url
    title = 'Page not found'
    message = 'The server was not able to display the requested page.'
    return dict(urls=urls, message=message, title=title)
示例#3
0
文件: cbz.py 项目: zcomx/zcomix.com
    def formatted_page_not_found():
        """Page not found formatter."""
        urls = Storage({})
        urls.invalid = '{scheme}://{host}{uri}'.format(
            scheme=request.env.wsgi_url_scheme or 'https',
            host=request.env.http_host,
            uri=request.env.web2py_original_uri or request.env.request_uri
        )

        urls.suggestions = []

        query = (db.book.cbz != None)
        book_row = db(query).select(
            db.book.id, orderby='<random>', limitby=(0, 1)).first()
        book = Book.from_id(book_row.id)
        if book:
            urls.suggestions.append({
                'label': 'CBZ file:',
                'url': cbz_url(book, host=True),
            })

        response.view = 'errors/page_not_found.html'
        message = 'The requested CBZ file was not found on this server.'
        return dict(urls=urls, message=message)