Move the cors middleware initialisation to pyramid-cubicweb to reduce code duplication
--- a/__pkginfo__.py Thu Oct 23 17:30:15 2014 +0200
+++ b/__pkginfo__.py Thu Nov 06 22:07:06 2014 +0100
@@ -13,7 +13,11 @@
description = "Add the 'pyramid' command to cubicweb-ctl"
web = 'http://www.cubicweb.org/project/%s' % distname
-__depends__ = {'cubicweb': '>= 3.19.3', 'wsgicors': '>= 0.3'}
+__depends__ = {
+ 'cubicweb': '>= 3.19.3',
+ 'wsgicors': '>= 0.3',
+ 'pyramid-cubicweb': '>= 0.1.2'
+}
__recommends__ = {}
classifiers = [
--- a/ccplugin.py Thu Oct 23 17:30:15 2014 +0200
+++ b/ccplugin.py Thu Nov 06 22:07:06 2014 +0100
@@ -14,13 +14,11 @@
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
-from pyramid_cubicweb import make_cubicweb_application
+from pyramid_cubicweb import wsgi_application_from_cwconfig
import waitress
MAXFD = 1024
@@ -267,18 +265,7 @@
host = cwconfig['interface']
port = cwconfig['port'] or 8080
- 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')
+ app = wsgi_application_from_cwconfig(cwconfig)
repo = cwconfig.repository()
try: