[python] Add default Configuration (#6554)

* Add default configuration

* Fix assert_hostname bug in rest.py

* Update petstore sample
This commit is contained in:
Mehdy Bohlool
2017-09-25 23:16:48 -07:00
committed by wing328
parent e2916fdc13
commit d2b91073e1
6 changed files with 66 additions and 6 deletions

View File

@@ -15,15 +15,30 @@ from __future__ import absolute_import
import urllib3
import copy
import logging
import multiprocessing
import sys
from six import iteritems
from six import with_metaclass
from six.moves import http_client as httplib
class TypeWithDefault(type):
def __init__(cls, name, bases, dct):
super(TypeWithDefault, cls).__init__(name, bases, dct)
cls._default = None
class Configuration(object):
def __call__(cls):
if cls._default == None:
cls._default = type.__call__(cls)
return copy.copy(cls._default)
def set_default(cls, default):
cls._default = copy.copy(default)
class Configuration(with_metaclass(TypeWithDefault, object)):
"""
NOTE: This class is auto generated by the swagger code generator program.
Ref: https://github.com/swagger-api/swagger-codegen

View File

@@ -78,7 +78,7 @@ class RESTClientObject(object):
addition_pool_args = {}
if configuration.assert_hostname is not None:
addition_pool_args['assert_hostname'] = config.assert_hostname
addition_pool_args['assert_hostname'] = configuration.assert_hostname
if maxsize is None:
if configuration.connection_pool_maxsize is not None: