Exemple #1
0
def _call_conf(cfg, parser):
    cfg.footers.append('eshop/_footer.html')
    if cfg.eshop_cart_in_menu:
        user_sections.append(MenuItem('/eshop/cart', label="Shopping Cart",
                             symbol="shopping-cart", role="shopping-cart"))
    if cfg.debug:
        app.set_route('/eshop/cart/wipe', eshop_cart_wipe)
Exemple #2
0
def refresh_links(req, cfg_timestamp, clear=True):
    """ refresh redirect links from db if timestamp is change """
    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, loading redirects from DB...",
                      state.LOG_INFO)

        if clear:
            for uri, hdls in app.handlers.items():
                if hdls.get(state.METHOD_GET) == redirect_uri:
                    app.pop_route(uri, state.METHOD_GET)
                    app.pop_route(uri, state.METHOD_HEAD)
        for it in Redirect.list(req, Pager(limit=-1), state=1):
            if it.src[-1] == '$':
                if not app.is_rroute(it.src):
                    req.cfg.log_info("Adding %s -> %s" % (it.src, it.dst))
                    app.set_rroute(it.src, redirect_ruri)
            else:
                if not app.is_route(it.src):
                    req.cfg.log_info("Adding %s -> %s" % (it.src, it.dst))
                    app.set_route(it.src, redirect_uri)

        timestamp = check
Exemple #3
0
def _call_conf(cfg, parser):
    def empty(req):
        return ()

    rights.update(cfg.pages_rights)
    if 'get_static_menu' not in cfg.__dict__:
        cfg.get_static_menu = empty             # set empty static menu
    if not cfg.pages_out:
        cfg.pages_runtime = True                # fallback for dynamic page
    if cfg.pages_index_is_root and not cfg.pages_runtime:
        app.set_route('/', root)                # redirect from / to index.html

    if cfg.pages_runtime:                       # auto register pages url
        refresh_page_files(cfg, cfg.pages_timestamp, False)
Exemple #4
0
def _call_conf(cfg, parser):
    cfg.form_web_templates += '/'
    cfg.form_mail_templates += '/'

    if cfg.form_paths:
        cfg.forms = {}

    for uri in cfg.form_paths:
        app.set_route('/form/' + uri.encode('utf-8'),
                      form_send, state.METHOD_GET_POST)

        f = Object()
        f.template = parser.get('form_%s' % uri, 'template')
        f.required = parser.get('form_%s' % uri, 'required', '', tuple)
        f.protection = parser.get('form_%s' % uri, 'protection', True, bool)
        f.answer = parser.get('form_%s' % uri, 'answer', '')
        f.recipient = parser.get('form_%s' % uri, 'recipient',
                                 cfg.form_recipient)
        f.subject = parser.get('form_%s' % uri, 'subject',
                               cfg.site_name + ': ' + uri)

        cfg.forms[uri] = f
Exemple #5
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
Exemple #6
0
def _call_conf(cfg, parser):
    if cfg.articles_in_menu:
        user_sections.append(Item('/articles', label="Articles"))
    if cfg.articles_is_root:
        app.set_route('/', articles_list_full)
Exemple #7
0
def _call_conf(cfg, parser):
    if cfg.login_sign_up:
        app.set_route("/sign_up", sign_up, state.METHOD_GET_POST)
    if cfg.login_forget_password_link:
        app.set_route("/login/forgotten_password", forgotten_password, state.METHOD_GET_POST)