Skip to content

Commit

Permalink
Update petstore sample
Browse files Browse the repository at this point in the history
  • Loading branch information
mbohlool committed Sep 24, 2017
1 parent 990f034 commit ef15aea
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ApiClient(object):

def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None):
if configuration is None:
configuration = Configuration()
configuration = Configuration.get_default()
self.configuration = configuration

self.pool = ThreadPool()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import urllib3

import copy
import logging
import multiprocessing
import sys
Expand All @@ -30,6 +31,18 @@ class Configuration(object):
Do not edit the class manually.
"""

_default_configuration = None

@classmethod
def get_default(cls):
if cls._default_configuration is None:
return Configuration()
return copy.copy(cls._default_configuration)

@classmethod
def set_default(cls, config):
cls._default_configuration = copy.copy(config)

def __init__(self):
"""
Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ApiClient(object):

def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None):
if configuration is None:
configuration = Configuration()
configuration = Configuration.get_default()
self.configuration = configuration

self.pool = ThreadPool()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import urllib3

import copy
import logging
import multiprocessing
import sys
Expand All @@ -30,6 +31,18 @@ class Configuration(object):
Do not edit the class manually.
"""

_default_configuration = None

@classmethod
def get_default(cls):
if cls._default_configuration is None:
return Configuration()
return copy.copy(cls._default_configuration)

@classmethod
def set_default(cls, config):
cls._default_configuration = copy.copy(config)

def __init__(self):
"""
Constructor
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/python/petstore_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ApiClient(object):

def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None):
if configuration is None:
configuration = Configuration()
configuration = Configuration.get_default()
self.configuration = configuration

self.pool = ThreadPool()
Expand Down
13 changes: 13 additions & 0 deletions samples/client/petstore/python/petstore_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import urllib3

import copy
import logging
import multiprocessing
import sys
Expand All @@ -30,6 +31,18 @@ class Configuration(object):
Do not edit the class manually.
"""

_default_configuration = None

@classmethod
def get_default(cls):
if cls._default_configuration is None:
return Configuration()
return copy.copy(cls._default_configuration)

@classmethod
def set_default(cls, config):
cls._default_configuration = copy.copy(config)

def __init__(self):
"""
Constructor
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 ef15aea

Please sign in to comment.