def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} try: exec(the_module, module_globals) except: # Log which file caused the exec error (traceback won't do it for # some reason) and relaunch the exception registerException('Error executing the module %s' % possible_module) raise if possible_handler in module_globals and \ callable(module_globals[possible_handler]): from indico.web.wsgi.indico_wsgi_handler_utils import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) _convert_to_string(form) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in \ str(err) or ('%s() takes at least' % possible_handler) in str(err): import inspect inspected_args = inspect.getargspec( module_globals[possible_handler]) expected_args = list(inspected_args[0]) expected_defaults = list(inspected_args[3]) expected_args.reverse() expected_defaults.reverse() # Write the exception to Apache error log file registerException("Wrong GET parameter set in calling a legacy " "publisher handler for %s: expected_args=%s, " "found_args=%s" % \ (possible_handler, repr(expected_args), repr(req.form.keys()))) cleaned_form = {} for index, arg in enumerate(expected_args): if arg == 'req': continue if index < len(expected_defaults): cleaned_form[arg] = form.get(arg, expected_defaults[index]) else: cleaned_form[arg] = form.get(arg, None) return _check_result( req, module_globals[possible_handler](req, **cleaned_form)) else: raise
def mp_legacy_publisher(req, possible_module, possible_handler): """ mod_python legacy publisher minimum implementation. """ the_module = open(possible_module).read() module_globals = {} try: exec(the_module, module_globals) except: # Log which file caused the exec error (traceback won't do it for # some reason) and relaunch the exception registerException("Error executing the module %s" % possible_module) raise if possible_handler in module_globals and callable(module_globals[possible_handler]): from indico.web.wsgi.indico_wsgi_handler_utils import _check_result ## the req.form must be casted to dict because of Python 2.4 and earlier ## otherwise any object exposing the mapping interface can be ## used with the magic ** form = dict(req.form) _convert_to_string(form) try: return _check_result(req, module_globals[possible_handler](req, **form)) except TypeError, err: if ("%s() got an unexpected keyword argument" % possible_handler) in str(err) or ( "%s() takes at least" % possible_handler ) in str(err): import inspect inspected_args = inspect.getargspec(module_globals[possible_handler]) expected_args = list(inspected_args[0]) expected_defaults = list(inspected_args[3]) expected_args.reverse() expected_defaults.reverse() # Write the exception to Apache error log file registerException( "Wrong GET parameter set in calling a legacy " "publisher handler for %s: expected_args=%s, " "found_args=%s" % (possible_handler, repr(expected_args), repr(req.form.keys())) ) cleaned_form = {} for index, arg in enumerate(expected_args): if arg == "req": continue if index < len(expected_defaults): cleaned_form[arg] = form.get(arg, expected_defaults[index]) else: cleaned_form[arg] = form.get(arg, None) return _check_result(req, module_globals[possible_handler](req, **cleaned_form)) else: raise
def plugin_publisher(req, path, rh, urlparams): """ Publishes the plugin described in path """ form = dict(req.form) _convert_to_string(form) return _check_result(req, rh(req, **urlparams).process(form))
def plugin_publisher(req, path, rh, urlparams): """ Publishes the plugin described in path """ form = dict(req.form) _convert_to_string(form) return _check_result(req, rh(req, **urlparams).process(form))