From 65c9886a00e835acc631fe2d9d1f7ac0bfeae569 Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Tue, 15 Mar 2016 00:04:59 +0100 Subject: [PATCH] Remove WSGI patch. --- issue92001_42002_52002_wsgi_protocol.diff | 104 ---------------------- series | 1 - 2 files changed, 105 deletions(-) delete mode 100644 issue92001_42002_52002_wsgi_protocol.diff diff --git a/issue92001_42002_52002_wsgi_protocol.diff b/issue92001_42002_52002_wsgi_protocol.diff deleted file mode 100644 index 7c8073e..0000000 --- a/issue92001_42002_52002_wsgi_protocol.diff +++ /dev/null @@ -1,104 +0,0 @@ -Index: trytond/protocols/wsgi/__init__.py -=================================================================== -new file mode 100644 ---- /dev/null -+++ b/trytond/trytond/protocols/wsgi/__init__.py -@@ -0,0 +1,98 @@ -+# This file is part of Tryton. The COPYRIGHT file at the top level of -+# this repository contains the full copyright notices and license terms. -+import sys -+import json -+import traceback -+import StringIO -+import gzip -+from BaseHTTPServer import BaseHTTPRequestHandler, DEFAULT_ERROR_MESSAGE -+from trytond.protocols.jsonrpc import JSONDecoder, JSONEncoder -+from trytond.protocols.dispatcher import dispatch -+from trytond.config import config -+from trytond.pool import Pool -+from trytond.exceptions import UserError, UserWarning, NotLogged, \ -+ ConcurrencyException -+ -+ -+def get_jsonrpc_app(): -+ config.update_etc() -+ -+ Pool.start() -+ -+ def f(environ, start_response): -+ 'JSON-RPC dispatcher' -+ def error_response(code): -+ message, explain = BaseHTTPRequestHandler.responses[code] -+ start_response('%d %s' % (code, message), -+ [('Content-Type', 'text/html')]) -+ return [DEFAULT_ERROR_MESSAGE % locals()] -+ -+ if environ['REQUEST_METHOD'] == 'POST': -+ body = '' -+ try: -+ length = int(environ.get('CONTENT_LENGTH', '0')) -+ except ValueError: -+ length = 0 -+ body = environ['wsgi.input'].read(length) -+ if environ.get('HTTP_CONTENT_ENCODING') == 'gzip': -+ f = StringIO.StringIO(body) -+ gzf = gzip.GzipFile(mode="rb", fileobj=f) -+ try: -+ decoded = gzf.read() -+ except IOError: -+ return error_response(400) -+ f.close() -+ gzf.close() -+ body = decoded -+ try: -+ rawreq = json.loads(body, object_hook=JSONDecoder()) -+ except ValueError: -+ return error_response(501) -+ req_id = rawreq.get('id', 0) -+ method = rawreq['method'] -+ params = rawreq.get('params', []) -+ -+ response = {'id': req_id} -+ database_name = environ['PATH_INFO'][1:] -+ if database_name.startswith('sao/'): -+ database_name = database_name[4:] -+ method_list = method.split('.') -+ object_type = method_list[0] -+ object_name = '.'.join(method_list[1:-1]) -+ method = method_list[-1] -+ args = ( -+ environ['SERVER_NAME'], -+ int(environ['SERVER_PORT']), -+ 'JSON-RPC', -+ database_name, -+ params[0], -+ params[1], -+ object_type, -+ object_name, -+ method -+ ) + tuple(params[2:]) -+ try: -+ response['result'] = dispatch(*args) -+ except (UserError, UserWarning, NotLogged, -+ ConcurrencyException), exception: -+ response['error'] = exception.args -+ except Exception: -+ tb_s = ''.join(traceback.format_exception(*sys.exc_info())) -+ for path in sys.path: -+ tb_s = tb_s.replace(path, '') -+ # report exception back to server -+ response['error'] = (str(sys.exc_value), tb_s) -+ -+ start_response('200 OK', -+ [('Content-Type', 'application/json-rpc')]) -+ return [json.dumps(response, cls=JSONEncoder)] -+ else: -+ return error_response(501) -+ return f -+ -+ -+if __name__ == '__main__': -+ from wsgiref.simple_server import make_server -+ jsonrpc_app = get_jsonrpc_app() -+ httpd = make_server('', 8000, jsonrpc_app) -+ httpd.serve_forever() diff --git a/series b/series index 136bc53..e9ccd9b 100644 --- a/series +++ b/series @@ -40,7 +40,6 @@ issue10091002_1.diff issue9911002_80001.diff issue6021003_1.diff issue6951002_20001.diff -issue92001_42002_52002_wsgi_protocol.diff stock_supply_production-performance-improvement.diff