diff --git a/modules/webstyle/lib/webinterface_layout.py b/modules/webstyle/lib/webinterface_layout.py index 200d2073f..a4e4a1c7e 100644 --- a/modules/webstyle/lib/webinterface_layout.py +++ b/modules/webstyle/lib/webinterface_layout.py @@ -1,115 +1,218 @@ # -*- coding: utf-8 -*- ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ Global organisation of the application's URLs. This module binds together CDS Invenio's modules and maps them to their corresponding URLs (ie, /search to the websearch modules,...) """ __revision__ = \ "$Id$" from invenio.webinterface_handler import create_handler - -from invenio.websearch_webinterface import WebInterfaceSearchInterfacePages, \ - WebInterfaceAuthorPages, WebInterfaceRSSFeedServicePages, \ - WebInterfaceUnAPIPages -from invenio.websubmit_webinterface import websubmit_legacy_getfile, \ - WebInterfaceSubmitPages -from invenio.websession_webinterface import WebInterfaceYourAccountPages, \ - WebInterfaceYourGroupsPages -from invenio.webalert_webinterface import WebInterfaceYourAlertsPages -from invenio.webbasket_webinterface import WebInterfaceYourBasketsPages -from invenio.webcomment_webinterface import WebInterfaceCommentsPages -from invenio.webmessage_webinterface import WebInterfaceYourMessagesPages -from invenio.errorlib_webinterface import WebInterfaceErrorPages -from invenio.oai_repository_webinterface import WebInterfaceOAIProviderPages -from invenio.webstat_webinterface import WebInterfaceStatsPages -from invenio.bibcirculation_webinterface import WebInterfaceYourLoansPages - - -from invenio.webjournal_webinterface import WebInterfaceJournalPages - -from invenio.webdoc_webinterface import WebInterfaceDocumentationPages +from invenio.errorlib import register_exception +from invenio.webinterface_handler import WebInterfaceDirectory + +class WebInterfaceDumbPages(WebInterfaceDirectory): + """This class implements a dumb interface to use as a fallback in case of + errors importing particular module pages.""" + _exports = [''] + def __call__(self, req, form): + try: + from invenio.webpage import page + except ImportError: + page = lambda *args: args[1] + from mod_python import apache + req.status = apache.HTTP_INTERNAL_SERVER_ERROR + msg = "

This functionality is facing a temporary failure.

" + msg += "

The administrator has been informed about the problem.

" + try: + from invenio.config import CFG_SITE_ADMIN_EMAIL + msg += """

You can contact %s + in case of questions.

""" % \ + CFG_SITE_ADMIN_EMAIL + except ImportError: + pass + msg += """

We hope to restore the service soon.

+

Sorry for the inconvenience.

""" + try: + return page('Service failure', msg) + except: + return msg + + def _lookup(self, component, path): + return WebInterfaceDumbPages(), path + index = __call__ + +try: + from invenio.websearch_webinterface import WebInterfaceSearchInterfacePages +except: + register_exception(alert_admin=True) + WebInterfaceSearchInterfacePages = WebInterfaceDumbPages + +try: + from invenio.websearch_webinterface import WebInterfaceAuthorPages +except: + register_exception(alert_admin=True) + WebInterfaceAuthorPages = WebInterfaceDumbPages + +try: + from invenio.websearch_webinterface import WebInterfaceRSSFeedServicePages +except: + register_exception(alert_admin=True) + WebInterfaceRSSFeedServicePages = WebInterfaceDumbPages + +try: + from invenio.websearch_webinterface import WebInterfaceUnAPIPages +except: + register_exception(alert_admin=True) + WebInterfaceUnAPIPages = WebInterfaceDumbPages + +try: + from invenio.websubmit_webinterface import websubmit_legacy_getfile +except: + register_exception(alert_admin=True) + websubmit_legacy_getfile = WebInterfaceDumbPages + +try: + from invenio.websubmit_webinterface import WebInterfaceSubmitPages +except: + register_exception(alert_admin=True) + WebInterfaceSubmitPages = WebInterfaceDumbPages + +try: + from invenio.websession_webinterface import WebInterfaceYourAccountPages +except: + register_exception(alert_admin=True) + WebInterfaceYourAccountPages = WebInterfaceDumbPages + +try: + from invenio.websession_webinterface import WebInterfaceYourGroupsPages +except: + register_exception(alert_admin=True) + WebInterfaceYourGroupsPages = WebInterfaceDumbPages + +try: + from invenio.webalert_webinterface import WebInterfaceYourAlertsPages +except: + register_exception(alert_admin=True) + WebInterfaceYourAlertsPages = WebInterfaceDumbPages + +try: + from invenio.webbasket_webinterface import WebInterfaceYourBasketsPages +except: + register_exception(alert_admin=True) + WebInterfaceYourBasketsPages = WebInterfaceDumbPages + +try: + from invenio.webcomment_webinterface import WebInterfaceCommentsPages +except: + register_exception(alert_admin=True) + WebInterfaceCommentsPages = WebInterfaceDumbPages + +try: + from invenio.webmessage_webinterface import WebInterfaceYourMessagesPages +except: + register_exception(alert_admin=True) + WebInterfaceYourMessagesPages = WebInterfaceDumbPages + +try: + from invenio.errorlib_webinterface import WebInterfaceErrorPages +except: + register_exception(alert_admin=True) + WebInterfaceErrorPages = WebInterfaceDumbPages + +try: + from invenio.oai_repository_webinterface import WebInterfaceOAIProviderPages +except: + register_exception(alert_admin=True) + WebInterfaceOAIProviderPages = WebInterfaceDumbPages + +try: + from invenio.webstat_webinterface import WebInterfaceStatsPages +except: + register_exception(alert_admin=True) + WebInterfaceStatsPages = WebInterfaceDumbPages +try: + from invenio.bibcirculation_webinterface import WebInterfaceYourLoansPages +except: + register_exception(alert_admin=True) + WebInterfaceYourLoansPages = WebInterfaceDumbPages + +try: + from invenio.webjournal_webinterface import WebInterfaceJournalPages +except: + register_exception(alert_admin=True) + WebInterfaceJournalPages = WebInterfaceDumbPages + +try: + from invenio.webdoc_webinterface import WebInterfaceDocumentationPages +except: + register_exception(alert_admin=True) + WebInterfaceDocumentationPages = WebInterfaceDumbPages class WebInterfaceInvenio(WebInterfaceSearchInterfacePages): """ The global URL layout is composed of the search API plus all the other modules.""" _exports = WebInterfaceSearchInterfacePages._exports + \ WebInterfaceAuthorPages._exports + [ 'youraccount', 'youralerts', 'yourbaskets', 'yourmessages', 'yourloans', 'yourgroups', 'comments', 'error', 'oai2d', ('oai2d.py', 'oai2d'), ('getfile.py', 'getfile'), 'submit', 'rss', 'stats', 'journal', 'help', 'unapi' ] def __init__(self): self.getfile = websubmit_legacy_getfile - return author = WebInterfaceAuthorPages() - submit = WebInterfaceSubmitPages() - youraccount = WebInterfaceYourAccountPages() - youralerts = WebInterfaceYourAlertsPages() - yourbaskets = WebInterfaceYourBasketsPages() - yourmessages = WebInterfaceYourMessagesPages() - yourloans = WebInterfaceYourLoansPages() - yourgroups = WebInterfaceYourGroupsPages() - comments = WebInterfaceCommentsPages() - error = WebInterfaceErrorPages() - oai2d = WebInterfaceOAIProviderPages() - rss = WebInterfaceRSSFeedServicePages() - stats = WebInterfaceStatsPages() - journal = WebInterfaceJournalPages() - help = WebInterfaceDocumentationPages() - unapi = WebInterfaceUnAPIPages() # This creates the 'handler' function, which will be invoked directly # by mod_python. handler = create_handler(WebInterfaceInvenio())