Skip to content

Commit

Permalink
[python] Add default Configuration (#6554)
Browse files Browse the repository at this point in the history
* Add default configuration

* Fix assert_hostname bug in rest.py

* Update petstore sample
  • Loading branch information
mbohlool authored and wing328 committed Sep 26, 2017
1 parent e2916fd commit d2b9107
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,30 @@

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,30 @@

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
Expand Down
17 changes: 16 additions & 1 deletion samples/client/petstore/python/petstore_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,30 @@

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
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/python/petstore_api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, configuration, pools_size=4, maxsize=None):

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:
Expand Down

0 comments on commit d2b9107

Please sign in to comment.