Ejemplo n.º 1
0
def admin_pages(req):
    check_login(req)
    match_right(req, module_rights)

    error = req.args.getfirst('error', 0, int)

    pager = Pager()
    pager.bind(req.args)

    if not do_match_right(req, ('pages_modify', 'pages_listall')):
        rows = Page.list(req, pager, author_id=req.login.id)
    else:
        rows = Page.list(req, pager)
    return generate_page(req, "admin/pages.html",
                         token=do_create_token(req, '/admin/pages'),
                         pager=pager, rows=rows, error=error)
Ejemplo n.º 2
0
def refresh_page_files(req, cfg_timestamp, clear=True):
    global timestamp
    check = check_timestamp(req, cfg_timestamp)
    if check > timestamp:       # if last load was in past to timestamp file
        req.log_error("file timestamp is older, refresh page_files ...",
                      state.LOG_INFO)

        if clear:
            for uri, hdls in app.handlers.items():
                if hdls.get(state.METHOD_GET) == runtime_file:
                    app.pop_route(uri, state.METHOD_GET)
                    app.pop_route(uri, state.METHOD_HEAD)

        if req.cfg.pages_index_is_root:
            app.set_route('/', runtime_file)                # / will be index
        if req.cfg.pages_runtime_without_html:
            for it in Page.list(req, Pager(limit=-1)):
                if not it.found:
                    req.cfg.log_error("Page %s not found" % it.name)
                    continue
                name = it.name[:it.name.rfind('.')]
                if name in ('admin', 'user', 'login', 'logout'):
                    req.cfg.log_error('Denied runtime file uri: %s' %
                                      it.name[:-5], state.LOG_ERR)
                    continue
                req.cfg.log_info("Adding /%s" % name)
                app.set_route('/'+name, runtime_file)   # without .html
        else:
            for it in Page.list(req, Pager(limit=-1)):
                if not it.found:
                    req.cfg.log_error("Page %s not found" % it.name)
                    continue
                req.cfg.log_info("Adding /%s" % name)
                # rst not work
                app.set_route('/'+it.name, runtime_file)

        timestamp = check