ccplugin.py
changeset 11640 e45e4999dc98
parent 11639 f38ec5e29de3
child 11641 3d4e7be2e3c3
--- 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: