Merge pull request #354 from silveregg/0.4.1-threadsafe

threadsafe fix
This commit is contained in:
Steve Pulec 2015-05-29 23:34:55 -04:00
commit 6a0e8df189
20 changed files with 33 additions and 21 deletions

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': AutoScalingResponse().dispatch, '{0}/$': AutoScalingResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': CloudFormationResponse().dispatch, '{0}/$': CloudFormationResponse.dispatch,
} }

View File

@ -5,5 +5,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': CloudWatchResponse().dispatch, '{0}/$': CloudWatchResponse.dispatch,
} }

View File

@ -82,7 +82,11 @@ class BaseResponse(_TemplateEnvironmentMixin):
default_region = 'us-east-1' default_region = 'us-east-1'
region_regex = r'\.(.+?)\.amazonaws\.com' region_regex = r'\.(.+?)\.amazonaws\.com'
def dispatch(self, request, full_url, headers): @classmethod
def dispatch(cls, *args, **kwargs):
return cls()._dispatch(*args, **kwargs)
def _dispatch(self, request, full_url, headers):
querystring = {} querystring = {}
if hasattr(request, 'body'): if hasattr(request, 'body'):

View File

@ -7,5 +7,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
"{0}/": DynamoHandler().dispatch, "{0}/": DynamoHandler.dispatch,
} }

View File

@ -240,7 +240,7 @@ class Table(object):
results = [] results = []
last_page = True # Once pagination is implemented, change this last_page = True # Once pagination is implemented, change this
possible_results = [item for item in list(self.all_items()) if item.hash_key == hash_key] possible_results = [item for item in list(self.all_items()) if isinstance(item, Item) and item.hash_key == hash_key]
if range_comparison: if range_comparison:
for result in possible_results: for result in possible_results:
if result.range_key.compare(range_comparison, range_objs): if result.range_key.compare(range_comparison, range_objs):

View File

@ -7,5 +7,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
"{0}/": DynamoHandler().dispatch, "{0}/": DynamoHandler.dispatch,
} }

View File

@ -7,5 +7,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/': EC2Response().dispatch, '{0}/': EC2Response.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': ELBResponse().dispatch, '{0}/$': ELBResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': ElasticMapReduceResponse().dispatch, '{0}/$': ElasticMapReduceResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': IamResponse().dispatch, '{0}/$': IamResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': KinesisResponse().dispatch, '{0}/$': KinesisResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': RDSResponse().dispatch, '{0}/$': RDSResponse.dispatch,
} }

View File

@ -7,5 +7,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': RDS2Response().dispatch, '{0}/$': RDS2Response.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': RedshiftResponse().dispatch, '{0}/$': RedshiftResponse.dispatch,
} }

View File

@ -74,7 +74,15 @@ def create_backend_app(service):
backend = BACKENDS[service] backend = BACKENDS[service]
for url_path, handler in backend.flask_paths.items(): for url_path, handler in backend.flask_paths.items():
backend_app.route(url_path, methods=HTTP_METHODS)(convert_flask_to_httpretty_response(handler)) if handler.__name__ == 'dispatch':
endpoint = '{0}.dispatch'.format(handler.__self__.__name__)
else:
endpoint = None
backend_app.route(
url_path,
endpoint=endpoint,
methods=HTTP_METHODS)(convert_flask_to_httpretty_response(handler))
return backend_app return backend_app

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': EmailResponse().dispatch, '{0}/$': EmailResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': SNSResponse().dispatch, '{0}/$': SNSResponse.dispatch,
} }

View File

@ -6,6 +6,6 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': QueuesResponse().dispatch, '{0}/$': QueuesResponse.dispatch,
'{0}/(?P<account_id>\d+)/(?P<queue_name>[a-zA-Z0-9\-_]+)': QueueResponse().dispatch, '{0}/(?P<account_id>\d+)/(?P<queue_name>[a-zA-Z0-9\-_]+)': QueueResponse.dispatch,
} }

View File

@ -6,5 +6,5 @@ url_bases = [
] ]
url_paths = { url_paths = {
'{0}/$': TokenResponse().dispatch, '{0}/$': TokenResponse.dispatch,
} }