diff --git a/.gitignore b/.gitignore
index ea202dc..0286a10 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
orbeon/services/persistence_server/*.cfg
+*.pyc
diff --git a/orbeon/__init__.py b/orbeon/__init__.py
index cfe98f6..1765baf 100644
--- a/orbeon/__init__.py
+++ b/orbeon/__init__.py
@@ -21,3 +21,4 @@
import models
import services
import tests
+import controllers
diff --git a/orbeon/controllers/__init__.py b/orbeon/controllers/__init__.py
new file mode 100644
index 0000000..adf71d0
--- /dev/null
+++ b/orbeon/controllers/__init__.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# open2bizz
+# Copyright (C) 2016 open2bizz (open2bizz.nl).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import orbeon
diff --git a/orbeon/controllers/orbeon.py b/orbeon/controllers/orbeon.py
new file mode 100644
index 0000000..8dd0738
--- /dev/null
+++ b/orbeon/controllers/orbeon.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# Copyright (c) 2016 - Open2bizz
+# Author: Open2bizz
+#
+# This program 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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.
+#
+# A copy of the GNU General Public License is available at:
+# .
+#
+##############################################################################
+import requests
+from urlparse import urlparse
+from werkzeug.wrappers import Response
+from odoo import http
+import base64
+from odoo.tools import config
+import logging
+logger = logging.getLogger(__name__)
+
+class Orbeon(http.Controller):
+ orbeon_base_route = 'orbeon'
+
+ @http.route('/%s/' % orbeon_base_route, type='http', auth="user", csrf=False)
+ def render_orbeon_page(self, path, redirect=None, **kw):
+ orbeon_server = http.request.env["orbeon.server"].search_read([], ['url'])
+ if len(orbeon_server) == 0:
+ return 'Orbeon server not found'
+ else :
+ orbeon_server = orbeon_server[0]
+ o = urlparse(orbeon_server['url'])
+
+ odoo_session = http.request.session
+
+ orbeon_headers = ['cookie']
+ in_headers = { name : value for (name, value) in http.request.httprequest.headers.items()
+ if name.lower() in orbeon_headers}
+
+ in_headers.update({'Openerp-Server' : 'localhost'})
+ in_headers.update({'Openerp-Port' : str(config.get('xmlrpc_port'))})
+ in_headers.update({'Openerp-Database' : odoo_session.get('db') })
+ in_headers.update({'Authorization' : 'Basic %s' % base64.b64encode("%s:%s" % (odoo_session.get('login'), odoo_session.get('password')) ) } )
+
+ logger.debug('Calling Orbeon on url %s with header %s' % (o.netloc, in_headers))
+ curl = urlparse(http.request.httprequest.url)._replace(netloc=o.netloc)
+
+ resp = requests.request(
+ method=http.request.httprequest.method,
+ url=curl.geturl(),
+ headers=in_headers,
+ data=http.request.httprequest.get_data(),
+ #cookies=http.request.httprequest.cookies,
+ allow_redirects=False)
+
+ excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection'
+ , 'openerp-server', 'openerp-port', 'openerp-database', 'authorization' ]
+ headers = [(name, value) for (name, value) in resp.raw.headers.items()
+ if name.lower() not in excluded_headers]
+
+ response = Response(resp.content, resp.status_code, headers)
+ return response
+
\ No newline at end of file
diff --git a/orbeon/i18n/nl.po b/orbeon/i18n/nl.po
index c14c3d3..9c41f6e 100644
--- a/orbeon/i18n/nl.po
+++ b/orbeon/i18n/nl.po
@@ -501,7 +501,7 @@ msgstr "Start persistence"
#: model:ir.model.fields,field_description:orbeon.field_orbeon_builder_state
#: model:ir.model.fields,field_description:orbeon.field_orbeon_runner_state
msgid "State"
-msgstr "Staat / Provincie"
+msgstr "Status"
#. module: orbeon
#: model:ir.ui.view,arch_db:orbeon.orbeon_server_form
diff --git a/orbeon/models/orbeon_builder.py b/orbeon/models/orbeon_builder.py
index c846674..4e0d9dd 100644
--- a/orbeon/models/orbeon_builder.py
+++ b/orbeon/models/orbeon_builder.py
@@ -291,7 +291,7 @@ def _get_url(self):
else:
builder_id = self.id
- builder_url = "%s/%s" % (self.server_id.url, "fr/orbeon/builder")
+ builder_url = "/orbeon/%s" % ("fr/orbeon/builder")
get_mode = {STATE_NEW: 'edit'}
url = "%s/%s/%i" % (builder_url, get_mode.get(self.state, 'view'), builder_id)
diff --git a/orbeon/models/orbeon_runner.py b/orbeon/models/orbeon_runner.py
index cd6b229..f474d45 100644
--- a/orbeon/models/orbeon_runner.py
+++ b/orbeon/models/orbeon_runner.py
@@ -133,9 +133,8 @@ def _get_url(self):
if isinstance(rec.id, models.NewId) and not rec.builder_id.id:
return rec.url
- server_url = rec.builder_id.server_id.url
- base_path = 'fr/orbeon/runner'
- base_url = "%s/%s" % (server_url, base_path)
+ base_path = 'fr/b!%s!%s/runner' % (rec.builder_id.id, rec.id)
+ base_url = "/orbeon/%s" % (base_path)
if isinstance(rec.id, models.NewId):
url = "%s/new" % base_url
diff --git a/orbeon/models/orbeon_server.py b/orbeon/models/orbeon_server.py
index f8bf920..6d86a75 100644
--- a/orbeon/models/orbeon_server.py
+++ b/orbeon/models/orbeon_server.py
@@ -69,13 +69,9 @@ class OrbeonServer(models.Model):
)
url = fields.Char(
"URL",
+ help='URL relative to Odoo server, the Odoo server will open the URL and proxy the response',
required=True,
)
- summary_url = fields.Char(
- "Summary URL",
- compute="_set_summary_url",
- store=True,
- )
description = fields.Text(
"Description"
)
@@ -138,15 +134,6 @@ def __init__(self, pool, cr):
self._autostart_persistence_servers(pool, cr)
return res
- @api.one
- @api.depends("url")
- def _set_summary_url(self):
- if self.url:
- url = "%s/fr/orbeon/builder/summary" % self.url
- else:
- url = "Enter URL"
- self.summary_url = url
-
@api.constrains("name")
def constraint_unique_name(self):
cur_record = self.search([("name", "=", self.name)])
diff --git a/orbeon/services/persistence_server/orbeon_handlers.py b/orbeon/services/persistence_server/orbeon_handlers.py
index 09b9b0d..1b4e9db 100644
--- a/orbeon/services/persistence_server/orbeon_handlers.py
+++ b/orbeon/services/persistence_server/orbeon_handlers.py
@@ -181,17 +181,14 @@ def __init__(self, app, form, data_type, path=(), args={}, data=None):
super(RunnerHandler, self).__init__(app, form, data_type, path, args, data)
self.model = 'orbeon.runner'
- self.form_doc_id = path[5] if len(path) > 5 else None
+ self.form_doc_id = path[2].split('!')[2]
self.form_data_id = path[6] if len(path) > 6 else None
def read(self):
"""Get Orbeon-Runner data by read (i.e. HTTP GET)"""
-
if self.data_type == 'form':
- # Builder form data (definition)
- form_doc_id = self.args.get('document')
record = self.xmlrpc.runner_search_read_builder(
- [[("id", "=", form_doc_id)]],
+ [[("id", "=", self.form_doc_id)]],
["xml"],
)
return record.get("xml")
diff --git a/orbeon/views/orbeon_runner.xml b/orbeon/views/orbeon_runner.xml
index 4dbdd9d..1ccc61c 100644
--- a/orbeon/views/orbeon_runner.xml
+++ b/orbeon/views/orbeon_runner.xml
@@ -8,7 +8,7 @@