Use 'wsgicors' for CORS handling.
The CW CORS handling (in web/cors.py) is only able to work on cubicweb requests.
When a request is not handled by bwcompat, we need a proper solution.
The `wsgicors` library provides what we need as a wsgi middleware.
--- a/__pkginfo__.py Fri Sep 19 18:23:57 2014 +0200
+++ b/__pkginfo__.py Fri Sep 19 19:20:35 2014 +0200
@@ -13,7 +13,7 @@
description = "Add the 'pyramid' command to cubicweb-ctl"
web = 'http://www.cubicweb.org/project/%s' % distname
-__depends__ = {'cubicweb': '>= 3.19.3'}
+__depends__ = {'cubicweb': '>= 3.19.3', 'wsgicors': '>= 0.3'}
__recommends__ = {}
classifiers = [
--- a/ccplugin.py Fri Sep 19 18:23:57 2014 +0200
+++ b/ccplugin.py Fri Sep 19 19:20:35 2014 +0200
@@ -14,6 +14,8 @@
import threading
import subprocess
+import wsgicors
+
from cubicweb import BadCommandUsage, ExecutionError
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
from cubicweb.cwctl import CWCTL, InstanceCommand, init_cmdline_log_threshold
@@ -263,11 +265,21 @@
pyramid_config = make_cubicweb_application(cwconfig)
+ app = pyramid_config.make_wsgi_app()
+
+ # This replaces completely web/cors.py, which is not used by
+ # pyramid_cubicweb anymore
+ app = wsgicors.CORS(
+ app,
+ origin=' '.join(cwconfig['access-control-allow-origin']),
+ headers=','.join(cwconfig['access-control-allow-headers']),
+ methods=','.join(cwconfig['access-control-allow-methods']),
+ credentials='true')
+
repo = cwconfig.repository()
try:
repo.start_looping_tasks()
- waitress.serve(
- pyramid_config.make_wsgi_app(), host=host, port=port)
+ waitress.serve(app, host=host, port=port)
finally:
repo.shutdown()
if self._needreload: