Merge "Make internal client work with conf.d"
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
from eventlet import sleep, Timeout
|
from eventlet import sleep, Timeout
|
||||||
from eventlet.green import httplib, socket, urllib2
|
from eventlet.green import httplib, socket, urllib2
|
||||||
import json
|
import json
|
||||||
from paste.deploy import loadapp
|
|
||||||
import struct
|
import struct
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
import zlib
|
import zlib
|
||||||
@@ -27,6 +26,7 @@ from zlib import compressobj
|
|||||||
from swift.common.utils import quote
|
from swift.common.utils import quote
|
||||||
from swift.common.http import HTTP_NOT_FOUND
|
from swift.common.http import HTTP_NOT_FOUND
|
||||||
from swift.common.swob import Request
|
from swift.common.swob import Request
|
||||||
|
from swift.common.wsgi import loadapp
|
||||||
|
|
||||||
|
|
||||||
class UnexpectedResponse(Exception):
|
class UnexpectedResponse(Exception):
|
||||||
@@ -136,7 +136,7 @@ class InternalClient(object):
|
|||||||
|
|
||||||
def __init__(self, conf_path, user_agent, request_tries,
|
def __init__(self, conf_path, user_agent, request_tries,
|
||||||
allow_modify_pipeline=False):
|
allow_modify_pipeline=False):
|
||||||
self.app = loadapp('config:' + conf_path,
|
self.app = loadapp(conf_path,
|
||||||
allow_modify_pipeline=allow_modify_pipeline)
|
allow_modify_pipeline=allow_modify_pipeline)
|
||||||
self.user_agent = user_agent
|
self.user_agent = user_agent
|
||||||
self.request_tries = request_tries
|
self.request_tries = request_tries
|
||||||
|
@@ -305,11 +305,12 @@ def loadcontext(object_type, uri, name=None, relative_to=None,
|
|||||||
global_conf=global_conf)
|
global_conf=global_conf)
|
||||||
|
|
||||||
|
|
||||||
def loadapp(conf_file, global_conf, allow_modify_pipeline=True):
|
def loadapp(conf_file, global_conf=None, allow_modify_pipeline=True):
|
||||||
"""
|
"""
|
||||||
Loads a context from a config file, and if the context is a pipeline
|
Loads a context from a config file, and if the context is a pipeline
|
||||||
then presents the app with the opportunity to modify the pipeline.
|
then presents the app with the opportunity to modify the pipeline.
|
||||||
"""
|
"""
|
||||||
|
global_conf = global_conf or {}
|
||||||
ctx = loadcontext(loadwsgi.APP, conf_file, global_conf=global_conf)
|
ctx = loadcontext(loadwsgi.APP, conf_file, global_conf=global_conf)
|
||||||
if ctx.object_type.name == 'pipeline':
|
if ctx.object_type.name == 'pipeline':
|
||||||
# give app the opportunity to modify the pipeline context
|
# give app the opportunity to modify the pipeline context
|
||||||
|
@@ -187,7 +187,7 @@ class TestInternalClient(unittest.TestCase):
|
|||||||
|
|
||||||
def load(self, uri, allow_modify_pipeline=True):
|
def load(self, uri, allow_modify_pipeline=True):
|
||||||
self.load_called += 1
|
self.load_called += 1
|
||||||
self.test.assertEquals('config:' + conf_path, uri)
|
self.test.assertEquals(conf_path, uri)
|
||||||
self.test.assertFalse(allow_modify_pipeline)
|
self.test.assertFalse(allow_modify_pipeline)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user