@@ -31,17 +31,9 @@ class API(object):
3131 """
3232 Generic API to connect to magento
3333 """
34- __slots__ = (
35- 'url' ,
36- 'username' ,
37- 'password' ,
38- 'session' ,
39- 'client' ,
40- 'protocol' ,
41- )
4234
4335 def __init__ (self , url , username , password ,
44- version = '1.3.2.4' , full_url = False , protocol = 'xmlrpc' ):
36+ version = '1.3.2.4' , full_url = False , protocol = 'xmlrpc' , transport = None ):
4537 """
4638 This is the Base API class which other APIs have to subclass. By
4739 default the inherited classes also get the properties of this
@@ -53,8 +45,6 @@ class which will allow the use of the API with the `with` statement
5345
5446 class Core(API):
5547
56- __slots__ = ( )
57-
5848 def websites(self):
5949 return self.call('ol_websites.list', [])
6050
@@ -106,13 +96,17 @@ def store_views(self):
10696 :param full_url: If set to true, then the `url` is expected to
10797 be a complete URL
10898 :param protocol: 'xmlrpc' and 'soap' are valid values
99+ :param transport: optional xmlrpclib.Transport subclass for
100+ use in xmlrpc requests
109101 """
110102 assert protocol \
111103 in PROTOCOLS , "protocol must be %s" % ' OR ' .join (PROTOCOLS )
112104 self .url = str (full_url and url or expand_url (url , protocol ))
113105 self .username = username
114106 self .password = password
115107 self .protocol = protocol
108+ self .version = version
109+ self .transport = transport
116110 self .session = None
117111 self .client = None
118112
@@ -122,7 +116,11 @@ def connect(self):
122116 but does not login. This could be used as a connection test
123117 """
124118 if self .protocol == 'xmlrpc' :
125- self .client = ServerProxy (self .url , allow_none = True )
119+ if self .transport :
120+ self .client = ServerProxy (
121+ self .url , allow_none = True , transport = self .transport )
122+ else :
123+ self .client = ServerProxy (self .url , allow_none = True )
126124 else :
127125 self .client = Client (self .url )
128126
@@ -171,3 +169,4 @@ def multiCall(self, calls):
171169 return self .client .multiCall (self .session , calls )
172170 else :
173171 return self .client .service .multiCall (self .session , calls )
172+
0 commit comments