From: erickson Date: Thu, 3 Apr 2008 03:26:49 +0000 (+0000) Subject: built an opensrf http translator proxy for paster so mod_python is not required for... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=75aa5dc21aa501fe475bb7efa226a98715f991d4;p=Evergreen.git built an opensrf http translator proxy for paster so mod_python is not required for development git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9205 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/oilsweb/development.ini b/Open-ILS/web/oilsweb/development.ini index f95da199b3..671e8646f3 100644 --- a/Open-ILS/web/oilsweb/development.ini +++ b/Open-ILS/web/oilsweb/development.ini @@ -67,6 +67,11 @@ local_templates = /openils/var/web/oilsweb/oilsweb/local_templates #oils_demo_workstation = BR1-demo +# when using the opensrf translator proxy, define the +# translator host and path here +#osrf_http_translator_host = localhost:80 +#osrf_http_translator_path = /osrf-http-translator + # Logging configuration diff --git a/Open-ILS/web/oilsweb/oilsweb/config/routing.py b/Open-ILS/web/oilsweb/oilsweb/config/routing.py index 6d1b4cc8a2..516b6949a9 100644 --- a/Open-ILS/web/oilsweb/oilsweb/config/routing.py +++ b/Open-ILS/web/oilsweb/oilsweb/config/routing.py @@ -27,6 +27,7 @@ def make_map(): map.connect(prefix+'admin/:action/:type/:id', controller='admin') map.connect(prefix+'admin/:action/:type', controller='admin') + map.connect('osrf-http-translator', controller='translator', action='proxy') ''' trying a different set of admin routes above... map.connect('acq_admin', 'oils/admin', controller='acq_admin') diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/translator.py b/Open-ILS/web/oilsweb/oilsweb/controllers/translator.py new file mode 100644 index 0000000000..0df6a559f2 --- /dev/null +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/translator.py @@ -0,0 +1,24 @@ +from oilsweb.lib.base import * +import urllib2, urllib, httplib +import osrf.json +import pylons + +class TranslatorController(BaseController): + ''' This controller acts as a proxy for the OpenSRF http translator + so that paster can handle opensrf AJAX requests. ''' + def proxy(self): + try: + headers = {} + for k,v in request.headers.iteritems(): + headers[k] = v + conn = httplib.HTTPConnection(pylons.config['osrf_http_translator_host']) + conn.request("POST", pylons.config['osrf_http_translator_path'], + urllib.urlencode({'osrf-msg':request.params['osrf-msg']}), headers) + resp = conn.getresponse() + for h in resp.getheaders(): + response.headers[h[0]] = h[1] + return resp.read() + except Exception, e: + import sys + sys.stderr.write(unicode(e) + '\n') +