From b5d4bc4681797c2a3e56a44bb57f9c986c581c5c Mon Sep 17 00:00:00 2001 From: Leonardo Rossi Date: Tue, 12 May 2015 13:32:25 +0000 Subject: [PATCH] redirector: invenio.config deprecation * Replaces usage of invenio.config with invenio.base.globals:cfg. (addresses #3106) Signed-off-by: Leonardo Rossi --- .../redirect_methods/goto_plugin_latest_record.py | 7 ++++--- .../redirector/redirect_methods/goto_plugin_simple.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/invenio/modules/redirector/redirect_methods/goto_plugin_latest_record.py b/invenio/modules/redirector/redirect_methods/goto_plugin_latest_record.py index 8aa0e335b8..79ab05ae54 100644 --- a/invenio/modules/redirector/redirect_methods/goto_plugin_latest_record.py +++ b/invenio/modules/redirector/redirect_methods/goto_plugin_latest_record.py @@ -24,12 +24,12 @@ (of a collection). """ -from invenio.config import CFG_SITE_NAME, CFG_SITE_RECORD +from invenio.base.globals import cfg from invenio.legacy.search_engine import perform_request_search from invenio.legacy.bibdocfile.api import BibRecDocs, InvenioBibDocFileError -def goto(cc=CFG_SITE_NAME, p='', f='', sf='date', so='d', +def goto(cc=None, p='', f='', sf='date', so='d', docname='', format=''): """ Redirect the user to the latest record in the given collection. @@ -41,12 +41,13 @@ def goto(cc=CFG_SITE_NAME, p='', f='', sf='date', so='d', only a single bibdoc attached to the record will redirect to that one. """ + cc = cc or cfg['CFG_SITE_NAME'] recids = perform_request_search(cc=cc, p=p, f=f, sf=sf, so=so) if recids: # The first is the most recent because they are sorted by date # descending. recid = recids[0] - url = '/%s/%s' % (CFG_SITE_RECORD, recid) + url = '/%s/%s' % (cfg['CFG_SITE_RECORD'], recid) if format: bibrecdocs = BibRecDocs(recid) if not docname: diff --git a/invenio/modules/redirector/redirect_methods/goto_plugin_simple.py b/invenio/modules/redirector/redirect_methods/goto_plugin_simple.py index 1b34be9591..b72cb8f5eb 100644 --- a/invenio/modules/redirector/redirect_methods/goto_plugin_simple.py +++ b/invenio/modules/redirector/redirect_methods/goto_plugin_simple.py @@ -19,12 +19,13 @@ """Simple plugin to register an internal redirection.""" -from invenio.config import CFG_SITE_URL, CFG_SITE_SECURE_URL +from invenio.base.globals import cfg def goto(url): """Redirect to url (assuming it is internal to the system).""" if url.startswith('/'): - url = CFG_SITE_URL + url - if url.startswith(CFG_SITE_URL) or url.startswith(CFG_SITE_SECURE_URL): + url = cfg['CFG_SITE_URL'] + url + if url.startswith(cfg['CFG_SITE_URL']) or \ + url.startswith(cfg['CFG_SITE_SECURE_URL']): return url