Skip to content

Commit

Permalink
global: removal of custom remote debugger support
Browse files Browse the repository at this point in the history
* INCOMPATIBLE Removes support for custom remote debuggers.
  (closes inveniosoftware#2945)

Signed-off-by: Jiri Kuncar <[email protected]>
  • Loading branch information
jirikuncar committed Mar 26, 2015
1 parent 1c4ec8b commit 8d4b15f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 752 deletions.
10 changes: 0 additions & 10 deletions invenio/base/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,6 @@ def create_wsgi_app(*args, **kwargs):
"""Create WSGI application."""
app = create_app(*args, **kwargs)

# Start remote debugger if appropriate:
if app.config.get('CFG_REMOTE_DEBUGGER_ENABLED'):
try:
from invenio.utils import remote_debugger
remote_debugger.start_file_changes_monitor()
if app.config.get('CFG_REMOTE_DEBUGGER_WSGI_LOADING'):
remote_debugger.start()
except Exception as e:
app.logger.error('Remote debugger is not working', e)

@app.before_first_request
def pre_load():
"""Pre-load citation dictionaries upon WSGI application start-up.
Expand Down
39 changes: 16 additions & 23 deletions invenio/ext/legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,16 @@
import os
import sys

# Import the remote debugger as a first thing, if allowed
# FIXME enable remote_debugger when invenio.config is ready
# try:
# from invenio.utils import remote_debugger
# except:
# remote_debugger = None

from werkzeug.exceptions import HTTPException
from werkzeug.wrappers import BaseResponse
from flask import (request, g, current_app, render_template, abort,
from flask import (abort, current_app, g, render_template, request,
send_from_directory, url_for)
from flask_admin.menu import MenuLink

from invenio.base import signals
from invenio.base.scripts.database import create, recreate

from werkzeug.exceptions import HTTPException
from werkzeug.wrappers import BaseResponse

from .request_class import LegacyRequest


Expand Down Expand Up @@ -69,14 +63,14 @@ def cli_cmd_reset(sender, yes_i_know=False, drop=True, **kwargs):

def setup_app(app):
"""Setup up the app."""
## Legacy config support
USE_X_SENDFILE = app.config.get('CFG_BIBDOCFILE_USE_XSENDFILE')
DEBUG = app.config.get('CFG_DEVEL_SITE', 0) > 0
app.config.setdefault('USE_X_SENDFILE', USE_X_SENDFILE)
app.config.setdefault('DEBUG', DEBUG)
# Legacy config support
_use_x_sendfile = app.config.get('CFG_BIBDOCFILE_USE_XSENDFILE')
_debug = app.config.get('CFG_DEVEL_SITE', 0) > 0
app.config.setdefault('USE_X_SENDFILE', _use_x_sendfile)
app.config.setdefault('DEBUG', _debug)
app.debug = app.config['DEBUG']

## Legacy directory that must exist
# Legacy directory that must exist
for cfg_dir in ['CFG_BATCHUPLOADER_DAEMON_DIR',
'CFG_BIBDOCFILE_FILEDIR',
'CFG_BIBENCODE_DAEMON_DIR_NEWJOBS',
Expand Down Expand Up @@ -112,10 +106,7 @@ def __init__(self, app):
self.app = app

def __call__(self, environ, start_response):
#FIXME
#if remote_debugger:
# remote_debugger.start()

"""Wrapper for legacy calls."""
with self.app.request_context(environ):
g.start_response = start_response
try:
Expand All @@ -127,7 +118,7 @@ def __call__(self, environ, start_response):

return response(environ, start_response)

## Set custom request class.
# Set custom request class.
app.request_class = LegacyRequest
app.wsgi_app = LegacyAppMiddleware(app)

Expand Down Expand Up @@ -159,8 +150,10 @@ def web_admin(module, action, arguments=None):
possible_module, possible_handler = is_mp_legacy_publisher_path(
request.environ['PATH_INFO'])
if possible_module is not None:
legacy_publisher = lambda req: \
mp_legacy_publisher(req, possible_module, possible_handler)

def legacy_publisher(req):
return mp_legacy_publisher(req, possible_module,
possible_handler)
return legacy_application(request.environ, g.start_response,
handler=legacy_publisher)
return render_template('404.html'), 404
Expand Down
42 changes: 14 additions & 28 deletions invenio/ext/legacy/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 CERN.
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand All @@ -17,42 +17,34 @@
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

"""
Apache request handler mechanism.
"""Apache request handler mechanism.
It gives the tools to map url to functions, handles the legacy url
scheme (/search.py queries), HTTP/HTTPS switching, language
specification,...
"""

__revision__ = "$Id$"

# Import the remote debugger as a first thing, if allowed
try:
import invenio.utils.remote_debugger as remote_debugger
except:
remote_debugger = None

import urlparse
import cgi
import sys
import re
import os
import gc
import re
import urlparse
import warnings

from flask import session
from invenio.utils import apache
from invenio.config import CFG_SITE_URL, CFG_SITE_SECURE_URL, \
CFG_SITE_RECORD, CFG_ACCESS_CONTROL_LEVEL_SITE

from invenio.base.i18n import wash_language
from invenio.utils.url import redirect_to_url
from invenio.ext.login import current_user, login_user
from invenio.config import (
CFG_ACCESS_CONTROL_LEVEL_SITE,
CFG_SITE_RECORD,
CFG_SITE_SECURE_URL,
CFG_SITE_URL,
)
from invenio.ext.logging import register_exception
from invenio.ext.login import current_user, login_user
from invenio.legacy.wsgi.utils import StringField
from invenio.modules import apikeys as web_api_key
from invenio.legacy.wsgi.utils import StringField
from invenio.modules.access.engine import acc_authorize_action
from invenio.utils import apache
from invenio.utils.url import redirect_to_url


# The following variable is True if the installation make any difference
Expand Down Expand Up @@ -349,12 +341,6 @@ def _handler(req):
raise
except Exception:
# send the error message, much more convenient than log hunting
if remote_debugger:
args = {}
if req.args:
args = cgi.parse_qs(req.args)
if 'debug' in args:
remote_debugger.error_msg(args['debug'])
register_exception(req=req, alert_admin=True)
raise

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- mode: html; coding: utf-8; -*-

# This file is part of Invenio.
# Copyright (C) 2007, 2008, 2010, 2011 CERN.
# Copyright (C) 2007, 2008, 2010, 2011, 2015 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -34,8 +34,5 @@ the MiscUtil internals.

<dt><a href="miscutil-dateutils">Date handling library</a> </dt>
<dd>Explains how to handle dates in Invenio. All mentioned functions are represented with signature and additional explanations.</dd>

<dt><a href="miscutil-remote-debugger">Remote Debugger</a> </dt>
<dd>Explains how to (remote) debug Apache WSGI applications.</dd>
</dl>
</blockquote>
100 changes: 0 additions & 100 deletions invenio/legacy/miscutil/doc/hacking/miscutil-remote-debugger.webdoc

This file was deleted.

Loading

0 comments on commit 8d4b15f

Please sign in to comment.